Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS div 100% height

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.

like image 661
T1T Avatar asked Jan 31 '13 15:01

T1T


People also ask

How do I make my HTML height 100%?

With no height value provided for the HTML element, setting the height and/or min-height of the body element to 100% results in no height (before you add content).

Why is my div full height?

That is because you have align-items: center for the flexbox in which case it will default to the content height. What you need to do is to remove that (let align-items: stretch come into play as it is the default) and also remove the height:100% from CASideBorder .


1 Answers

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

html, body {height: 100%}

like image 136
MildlySerious Avatar answered Sep 20 '22 09:09

MildlySerious