How to force child div to be 100% of parent div's height without specifying parent's height?

前端 未结 26 2222
刺人心
刺人心 2020-11-22 06:52

I have a site with the following structure:

<
26条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 07:38

    The easiest way to do this is to just fake it. A List Apart has covered this extensively over the years, like in this article from Dan Cederholm from 2004.

    Here's how I usually do it:

    You can easily add a header onto this design by wrapping #container in another div, embedding the header div as #container's sibling, and moving the margin and width styles to the parent container. Also, the CSS should be moved into a separate file and not kept inline, etc. etc. Finally, the clearfix class can be found on positioniseverything.

提交回复
热议问题