Simplest vertical alignment we can think of

后端 未结 5 896
情书的邮戳
情书的邮戳 2021-01-06 13:32

To sum it up, there are few approaches to align content vertically in container. These are main approaches (if you now some completely different way to do it, it would be ve

5条回答
  •  日久生厌
    2021-01-06 14:00

    If I need IE7 support, I tend to go for the "display: inline-block with an extra element" method. This does work in IE7 with a small change, here's an example.

    If I don't need IE7 support, I usually use the display: table-cell method.

    Sometimes, I can't use the display: table-cell method, typically when I need to use absolutely position something at the bottom of the element with display: table-cell. position: relative doesn't work on table cells, at least in Firefox. In those cases, I use the display: inline-block method, except that the "extra element" is inserted via :before, which keeps the HTML clean.

提交回复
热议问题