CSS div 100% height

T1T picture T1T · Jan 31, 2013 · Viewed 118.2k times · Source

I'm developing this website and I want the right sidebar to have 100% height.

body { 
    height: 100%; 
    min-height: 100%;
    position: relative;
}

mydiv { 
    height: 100%; 
    min-height: 100%; 
    position: absolute; 
    top: 0; 
    right: 0; 
    bottom: 0;
    width: 290px;
}

I've read a lot of answer, especially this (Prestaul answer): Setting 100% height on an absolutely positioned element when the content expands past the window size.

But for me this trick does not work, also the fiddle exemple doesn't work!

This is the jsfiddle working example.

This is the same code that doesn't work.

Answer

MildlySerious picture MildlySerious · Jan 31, 2013

Set the html tag, too. This way no weird position hacks are required.

html, body {height: 100%}