Using CSS to create div-elements with 100% height
- March 6th, 2010
- Posted in CSS . HTML
- By Mr. Nerd
- Write comment
Just a short note to myself: To create a div element, which takes up 100% of the height of a page, the parent elements (html AND body) need to be set to 100%!
html{
height: 100%;
}
body{
height: 100%;
}
div#fullHeight{
height: 100%;
}
Of course, the div element must be placed directly within the body, otherwise all parent elements also need to set the appropriate height. Oh, and watch out for margins and paddings, of course.