In order for a percentage value to work for height, the parent’s height must be determined. The only exception is the root element , which can be a percentage height. .
So, you’ve given all of your elements height, except for the , so what you should do is add this:
html {
height: 100%;
}
And your code should work fine.
* { padding: 0; margin: 0; }
html, body, #fullheight {
min-height: 100% !important;
height: 100%;
}
#fullheight {
width: 250px;
background: blue;
}
Lorem Ipsum
JsFiddle example.
Since nobody has mentioned this..
Modern Approach:
As an alternative to setting both the html/body element’s heights to 100%, you could also use viewport-percentage lengths:
5.1.2. Viewport-percentage lengths: the ‘vw’, ‘vh’, ‘vmin’, ‘vmax’ units
The viewport-percentage lengths are relative to the size of the initial containing block. When the height or width of the initial containing block is changed, they are scaled accordingly.
In this instance, you could use the value 100vh (which is the height of the viewport) – (example)
body {
height: 100vh;
}
Setting a min-height also works. (example)
body {
min-height: 100vh;
}
These units are supported in most modern browsers – support can be found here.