在 webkit 中清除浮动的最简单方法是什么?
我正在制作一个 Google Chrome 插件。因此,注入的CSS只需要在webkit中起作用。 webkit 特有的清除浮动的方法是什么?
通过清除浮动,我的意思是让父元素包围其中包含的所有浮动子元素。
I'm making a Google Chrome plugin. Therefore, the injected CSS need only work in webkit. What is the webkit-specific way of clearing floats?
By clearing floats, I mean make a parent element enclose all floating children contained within.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你不需要关心IE的bug,你可以做一个清晰的样式(让元素不占用空间),就像这样简单:
作为对比,考虑IE单字符高度bug的样式 添加清除标记的另
一种方法是在浮动的父元素上设置溢出样式,这将使其继续其子元素。例如,您可以使用
overflow:hidden
但不指定大小,这样父级将根据其子级调整大小。If you don't need to care about the IE bugs, you can make a clearing style (for an element not to take up space) as simple as:
as comparison, a style that takes the IE one-character-height bug into acount would be:
An alternative to adding a clearing tag, is to set an
overflow
style on the parent element of the floats, that will make it contin it's children. You can for example useoverflow:hidden
but without specifying a size, that way the parent will be sized by it's children.display: inline-block
成功了。display: inline-block
did the trick.