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

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

I have a site with the following structure:

<
26条回答
  •  醉酒成梦
    2020-11-22 07:23

    This is a frustrating issue that's dealt with designers all the time. The trick is that you need to set the height to 100% on BODY and HTML in your CSS.

    html,body {
        height:100%;
    }
    

    This seemingly pointless code is to define to the browser what 100% means. Frustrating, yes, but is the simplest way.

提交回复
热议问题