You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<divclass="wrapper"><divclass="left1"></div><divclass="left2"></div><divclass="right"></div><p>People come into your life for a reason, a season, or a lifetime.
When someone is in your life for a REASON, it is usually to meet a need you have expressed or just felt. They have come to assist you through a hard time, to provide you with guidance and support, to aid you physically, emotionally or spiritually. Then, suddenly, the person disappears from your life. Your need has been met; their work is done.</p></div>
<divclass="wrapper"><divclass="left1"></div><divclass="left2"></div><divclass="right"></div><p>People come into your life for a reason, a season, or a lifetime.</p><divstyle="clear: both;"></div></div>
<divclass="wrapper" style="overflow: hidden;"><divclass="left1"></div><divclass="left2"></div><divclass="right"></div><p>People come into your life for a reason, a season, or a lifetime.</p></div>
Values 值
Float Position 浮动元素定位
当一个元素浮动之后,它会被移出正常的文档流,然后向左或者向右平移,一直平移直到碰到了所处的容器的边框,或者碰到另外一个浮动的元素
Clearing the Float 清除浮动
浮动的元素的高度比它们所在的容器元素(是块元素)的高度小。然而如果块元素内的文本太短,不足以把块元素的大小撑到高度大于所有浮动元素的高度,我们可能会看到意想不到的效果:
clear 属性
当应用于 非浮动块 时,它将非浮动块的 边框边界 移动到所有相关浮动元素 外边界 的下方。这个行为作用时会导致 margin collapsing 不起作用
当应用于 浮动元素 时,它将元素的 外边界 移动到所有相关的浮动元素 外边界 的下方。这会影响后面浮动元素的布局,后面的浮动元素的位置无法高于它之前的元素
方法1. 添加空元素
方法 2. 设置 overflow
创建一个 BFC 清除浮动,设置
overflow
的值不为visible
也正是因为,上面例子中,
float
创建了几个 BFC,而又因为 BFC 的内部布局,是不会受外部影响的特性,就可以通过这个思路,创建一个包含所有float
的 BFC,使得几个float
成为 BFC 内部元素方法 3. Clearfix 方法
利用伪元素清除浮动
Float 实现常用布局
issue #47
参考
https://developer.mozilla.org/zh-CN/docs/CSS/float
https://developer.mozilla.org/zh-CN/docs/Web/CSS/clear
https://css-tricks.com/almanac/properties/f/float/
http://nec.netease.com/library/category/#grid
The text was updated successfully, but these errors were encountered: