2016-08-12 3 views
0

Я хочу сделать простой buble чат с помощью css. с базовым css (а не CSS3), потому что чат работает в IE и загружается программой VB. Я использую поплавок влево и вправо, но у меня проблема с этим изображением <code>enter image description here</code>простой HTML/CSS buble chat

пузырь слева и справа в строке. и то, что я хочу, как этот PICT enter image description here

это мой пример кода

<div style="width:600px;"> 
 
\t <div style="width:100%;"> 
 
\t \t <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius</span> 
 
\t </div> 
 
\t <div style="width:100%;"> 
 
\t \t <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span> 
 
\t </div> 
 
\t <div style="width:100%;"> 
 
\t \t <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span> 
 
\t </div> 
 
\t <div style="width:100%;"> 
 
\t \t <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span> 
 
\t </div> 
 
\t <div style="width:100%;"> 
 
\t \t <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The </span> 
 
\t </div> 
 
\t <div style="width:100%;"> 
 
\t \t <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius elements.</span> 
 
\t </div> 
 
</div>

ответ

1

Добавить это в CSS

div { clear:both; } 
2

Попробуйте этот код с clearfix:

<div style="width:600px;"> 
 
    <div style="width:100%;"> 
 
    <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius</span> 
 
    <div style="clear: both"></div> 
 
    </div> 
 
    <div style="width:100%;"> 
 
    <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span> 
 
    <div style="clear: both"></div> 
 
    </div> 
 
    <div style="width:100%;"> 
 
    <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span> 
 
    <div style="clear: both"></div> 
 
    </div> 
 
    <div style="width:100%;"> 
 
    <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span> 
 
    <div style="clear: both"></div> 
 
    </div> 
 
    <div style="width:100%;"> 
 
    <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The </span> 
 
    <div style="clear: both"></div> 
 
    </div> 
 
    <div style="width:100%;"> 
 
    <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius elements.</span> 
 
    <div style="clear: both"></div> 
 
    </div> 
 
</div>

+2

нет необходимости добавлять дополнительные элементы DIV. Просто поставьте «clear: both;» на окружающий элемент (тот, который имеет «width: 100%») – user3528269

+0

вправо, это может быть и так и с меньшим количеством HTML, спасибо – ristapk

1

Тест его должен работать

div {clear: both;} 
+0

use clear: оба с любым тегом, который вы используете –

1

<div style="width:600px;"> 
 
\t <div style="display: block; width: 100%; float: left;"> 
 
\t \t <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius</span> 
 
\t </div> 
 
\t <div style="display: block; width: 100%; float: right;"> 
 
\t \t <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span> 
 
\t </div> 
 
\t <div style="display: block; width: 100%; float: right;"> 
 
\t \t <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span> 
 
\t </div> 
 
\t <div style="display: block; width: 100%; float: left;"> 
 
\t \t <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius property allows you to add rounded corners to elements.</span> 
 
\t </div> 
 
\t <div style="display: block; width: 100%; float: right;"> 
 
\t \t <span style="background:#ff4d4d;padding:10px;float:right;margin-top:5px;">The </span> 
 
\t </div> 
 
\t <div style="display: block; width: 100%; float: left;"> 
 
\t \t <span style="background:#e5e5e5;padding:10px;float:left;margin-top:5px;">The border-radius elements.</span> 
 
\t </div>