Make a div fill the whole page in height

不问归期 提交于 2019-12-13 03:44:23

问题


I have a page with this structure:

topbar (100% width) sidebar content

i want the sidebar to fill all the remaining space of the screen in height.

I've tried with height: 100% in my css but doesn't work.

How can i do this? There is a way to do it using css or i have to use Javascript?


回答1:


To achieve this you need make sure the sidebar's parent containers have heights of 100%, too.

So, if you have a sidebar div, you have the body container, and the html container.

html, body, #sidebar { height: 100%; }



回答2:


Have you set the height of body height to 100% too? If not it won't fill up the rest of the page.



来源:https://stackoverflow.com/questions/7675107/make-a-div-fill-the-whole-page-in-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!