我可以使用哪些“ clearfix”方法?

若如初见. 提交于 2020-04-19 21:05:26

问题:

I have the age-old problem of a div wrapping a two-column layout. 我有一个古老的问题,即div包装了两列布局。 My sidebar is floated, so my container div fails to wrap the content and sidebar. 我的侧边栏处于浮动状态,因此我的容器div无法包装内容和侧边栏。

<div id="container">
  <div id="content"></div>
  <div id="sidebar"></div>
</div>

There seem to be numerous methods of fixing the clear bug in Firefox: 似乎有许多方法可以解决Firefox中的明显错误:

  • <br clear="all"/>
  • overflow:auto
  • overflow:hidden

In my situation, the only one that seems to work correctly is the <br clear="all"/> solution, which is a little bit scruffy. 在我的情况下,唯一似乎正确运行的方法是<br clear="all"/>解决方案,该解决方案有些麻烦。 overflow:auto gives me nasty scrollbars, and overflow:hidden must surely have side effects. overflow:auto给了我讨厌的滚动条,而overflow:hidden必须肯定有副作用。 Also, IE7 apparently shouldn't suffer from this problem due to its incorrect behaviour, but in my situation it's suffering the same as Firefox. 另外,由于它的不正确行为,IE7显然不应该遭受此问题的困扰,但就我而言,它与Firefox一样遭受痛苦。

Which method currently available to us is the most robust? 我们目前可以使用的哪种方法最可靠?


解决方案:

参考一: https://stackoom.com/question/szP/我可以使用哪些-clearfix-方法
参考二: https://oldbug.net/q/szP/What-methods-of-clearfix-can-I-use
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!