I'm trying to use percentage height with overflow-y:auto;
and instead of creating a scroll bar on the side of the div, it's using the page scroll bar.
Here's an example of want I'm getting at: http://jsfiddle.net/hmwe2jty/
Is it possible to use this property with percent height?
use this css for div which height must dimensioned in percents of parent element:
css .child { position: absolute; top: 10px; bottom: 0px; }
TL;DR Use the viewport height/width instead of a percentage. Change 100% to 100vh, and you're done!
EDIT:
The percentages take the precentage of the parent element. For example:
The new CSS3 viewport units use the user's viewport as a base. For example:
Because the body element is a bit weird, it's default behaviour is to shrink to fit is contents. So:
So, since the parent element is the body, you will need to use the new vw and vh units. Read a article on CSS Tricks
EDIT 2:
Another way to choose the viewport as parent would be to make the element's position either
fixed
orabsolute
. In that instance the parent would become the viewport, thus giving you the needed value.It is considering 100% of the parent, which is the body. Hence it occupies the height of complete space available. Specify height a lesser amount in % rather than 100 (if you specifically prefer percent). It is upto you what you chose.