Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making DIV height at least as tall as the page in CSS

Tags:

I have a DIV that I want to touch the bottom of the screen (for appearance reasons). Sometimes the content is enough tall to do that, but sometimes the content is too short and the DIV won't touch the bottom of the screen. Is there a simple workaround?

like image 398
Tower Avatar asked Mar 02 '10 13:03

Tower


2 Answers

If you set min-height to 100% for the DIV, you also need to include:

body, html {    height:100% } 

Elements expand to the size of their container, so make sure the container (being the page itself) has a height of 100% as well.

like image 165
Diodeus - James MacFarlane Avatar answered Oct 13 '22 22:10

Diodeus - James MacFarlane


For anyone reading this later (as I am) you can use

min-height: 100vh; 

The vh unit stands for viewport height and is a percent of the screen size.

like image 24
SilentVoid Avatar answered Oct 13 '22 23:10

SilentVoid