How can an html element fill out 100% of the remaining screen height, using css only?

后端 未结 17 1923
名媛妹妹
名媛妹妹 2020-12-22 16:13

I have a header element and a content element:

#header
#content

I want the header to be of fixed height and the content to fill up all the

17条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 16:57

    The trick to this is specifying 100% height on the html and body elements. Some browsers look to the parent elements (html, body) to calculate the height.

    
        
            
            
    html, body { height: 100%; } #Header { width: 960px; height: 150px; } #Content { height: 100%; width: 960px; }

提交回复
热议问题