rabbbit
72 天前
原文:
In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch). This is true even in the presence of floats (although a box's line boxes may shrink due to the floats), unless the box establishes a new block formatting context (in which case the box itself may become narrower due to the floats).
就是子元素从上到下排列,子元素左侧贴着父元素,除非子元素也是 block formatting context
不理解的话看这个
<div class="box">
<div class="float">I am a floated box!</div>
<p>I am content inside the container.</p>
</div>
.box {
border: 5px solid rebeccapurple;
}
.float {
float: left;
width: 200px;
height: 100px;
border: 1px solid black;
padding: 10px;
}
p {
background: rebeccapurple;
}