【问题标题】:Why developers use ::before pseudo element with display:table on parent divs为什么开发人员在父 div 上使用 ::before 伪元素和 display:table
【发布时间】:2019-08-17 04:34:12
【问题描述】:

我看到在大多数网站上,人们经常在父 <div>s ::before 上使用伪 content:''; (我知道你需要放置内容)display: table 和我不知道为什么。

【问题讨论】:

    标签: html css html-table pseudo-element display


    【解决方案1】:

    它被称为“clearfix”,您只需 google-ing1 即可了解更多信息。它有很多版本。截图中的可能是 Nicolas Gallagher 的版本,你可以阅读更多关于它的信息here

    1This提供简单的imo介绍

    【讨论】:

      【解决方案2】:

      “clearfix”是一种在所有子元素都浮动时修复父元素高度为零的技巧。这样,父母就可以保持它的高度。

      【讨论】:

        猜你喜欢
        • 2016-02-17
        • 2015-06-05
        • 2022-11-10
        • 1970-01-01
        • 2015-08-31
        • 1970-01-01
        • 1970-01-01
        • 2014-10-31
        • 2013-06-08
        相关资源
        最近更新 更多