Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS清除浮动的3个方法 #17

Open
hoperyy opened this issue Jun 25, 2017 · 0 comments
Open

CSS清除浮动的3个方法 #17

hoperyy opened this issue Jun 25, 2017 · 0 comments

Comments

@hoperyy
Copy link
Owner

hoperyy commented Jun 25, 2017

clear: both;

浮动末尾添加新标签或使用 ::after 为元素,设置样式为 clear:both

原理:清除浮动的块盒在 margin-top 上所产生的间距(clearance)的值与其 margin-top 之和应该足够使其 border-top 恰好与浮动元素的 margin-bottom 相邻接。

构造 BFC

构造 BFC 的方法

  • float 设置为非 none
  • overflow 设置为非 visible
  • display 设置为 table-cell, table-caption, inline-block
  • position 设置为 absolutefixed

IE6/7 下没有 BFC 的概念,但有类似 BFChas layout

has layout的方法

  • 有些元素本身就 has layout
  • 没有 has layout 的元素
    • position: absolute
    • float 不为 none
    • display: inline-block
    • height:除 auto 外任意值
    • width:除 auto 外任意值
    • zoom:除 normal 外任意值
    • overflowvisible (仅限 IE7)
@hoperyy hoperyy added the CSS label Jun 26, 2017
@hoperyy hoperyy added the 2014 label Aug 19, 2017
@hoperyy hoperyy removed the FE label Oct 12, 2017
@hoperyy hoperyy closed this as completed Apr 29, 2018
@hoperyy hoperyy reopened this May 29, 2018
@hoperyy hoperyy added CSS and removed CSS labels May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant