How (and why) to use display: table-cell (CSS)

后端 未结 4 546
再見小時候
再見小時候 2020-12-13 04:37

I have a site with a very active background (I\'m talking 6 or so different z-indexes here 2 with animations). I wanted a in the foreground that had conten

4条回答
  •  既然无缘
    2020-12-13 04:48

    How (and why) to use display: table-cell (CSS)

    I just wanted to mention, since I don't think any of the other answers did directly, that the answer to "why" is: there is no good reason, and you should probably never do this.

    In my over a decade of experience in web development, I can't think of a single time I would have been better served to have a bunch of

    s with display styles than to just have table elements.

    The only hypothetical I could come up with is if you have tabular data stored in some sort of non-HTML-table format (eg. a CSV file). In a very specific version of this case it might be easier to just add

    tags around everything and then add descendent-based styles, instead of adding actual table tags.

    But that's an extremely contrived example, and in all real cases I know of simply using table tags would be better.

提交回复
热议问题