CSS块格式上下文是如何工作的?
overflow:hidden
.
通过说“这种行为对柱状样式布局很有用。然而,它的主要用途是停止浮动,比如在”主内容“div中,实际上清除浮动的侧列,即在源代码中前面出现的浮动。”
.content { background: #eee; color #000; border: 3px solid #444; width: 500px; height: 200px;}.float { background: rgba(0, 0, 255, 0.5); border: 1px solid #00f; width: 150px; height: 150px; float: right;}p { background: #444; color: #fff;}
<div class="content"> <h3>This is a content box</h3> <p>It contains a left floated box, you can see the actual content div does go under the float, but that it is the <h3> and <p> <b>line boxes</b> that are shortened to make room for the float. This is normal behaviour.</p> <div class="float">floated box</div></div>
content
.content { background: #eee; color #000; border: 3px solid #444; width: 500px; height: 200px;}.float { background: rgba(0, 0, 255, 0.5); border: 1px solid #00f; width: 150px; height: 150px; float: right;}p { background: #444; color: #fff;}
<div class="content"> <div class="float">floated box</div> <h3>This is a content box</h3> <p>it contains a left floated box, you can see the actual content div does go under the float, but that it is the < h3> and <p> <b>line boxes</b> that are shortened to make room for the float, this is normal behaviour</p></div>
拉风的咖菲猫