Contain one div in another div
This question already has an answer here:
The problem is that you're using a float: left but aren't "clearing" anything after it. Non-positioned and non-floated elements act as if the floated element isn't there. since the floated element is out of flow in relation to other block elements. Meaning: since 'boxb1' has a 'float: left' it's parent will pretend that the 'boxb1' isn't there.
In the css add something like:
.clear {
clear: both;
}
The html could be changed like this:
<div class="container">
<div class="bba">
<h1 style="text-align: center">Text</h1>
<div id="boxb1">
<h3>box1</h3>
<div id="twlth" width="10%" height="6%"></div>
</div>
<div class="clear"></div>
</div>
Jsfiddle
See: http://www.smashingmagazine.com/2009/10/the-mystery-of-css-float-property/ for more info about this (and other potential solutions)
链接地址: http://www.djcxy.com/p/88434.html下一篇: 在另一个div中包含一个div