简体   繁体   English

用力推浮 <div> 在另一个下面 <div>

[英]Force push a floated <div> below another floated <div>

Visit for my sample: http://codepen.io/anon/pen/qKBfE 造访我的样本: http : //codepen.io/anon/pen/qKBfE

here is the css code as well: 这也是CSS代码:

.bubble
{
text-align:left;
color:white;
float:left;
position: relative;
padding: 10px;
background: #95a5a6;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
border-left: 5px solid #e67e22;
margin-bottom:2%;
margin-top:2%;
margin-right:300px;
}

Theres alot of useless code in there but please reference just the divs with 那里有很多无用的代码,但是请只引用div

class="bubble" | class="bubble2"

As you can see this is a chat box with custom chat bubbles, my "bubble" class is the host and the "bubble2" class is the client. 如您所见,这是一个带有自定义聊天气泡的聊天框,我的“气泡”类是主机,而“气泡2”类是客户端。

When "bubble" types in multiple messages they are not stacked rather they are displayed inline and only sometimes stack. 当在多个消息中键入“冒泡”时,它们不会堆叠,而是内联显示,有时仅堆叠。

How can i make sure that the each bubble pushes the other one down and floats left for the host and floats right for the client. 我如何确保每个气泡将另一个气泡推下并向主机浮动,向客户端浮动。

Adding 添加

clear:both;

As the first line for both .bubble and .bubble2 fixes it for me? 作为.bubble和.bubble2的第一行为我解决了吗? Is this what u want? 这就是你想要的吗?

.bubble2
{
  clear: both;
}

.bubble
{
  clear: both;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM