search

Home  >  Q&A  >  body text

css - .clearfix:after中为什么设置display: table

相较于display: block;有什么优点吗?

怪我咯怪我咯2809 days ago1051

reply all(4)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 11:32:45

    In fact, setting display: table actually uses the parent container to form a BFC
    and display: block does not clear the float. It uses clear: both to clear the float.
    It is recommended to take a look at this article, if you are interested, you can also study BFC
    CSS Clear Float (Clear and BFC)

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:32:45

    display:block will cause line breaks

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:32:45

    display:table will clear the floating elements before and after, but block will not

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:32:45

    Prevent margin merging

    reply
    0
  • Cancelreply