I'm trying to figure out a relatively browser-compatible way of allowing the height of a parent div to expand with its children of width: 100%
and some percentage height. I need the parent to have height: 100%
because the first child's height is dependent on it. I want a background image on the parent div that's aligned to the bottom of the entire page which overflows the screen, but the parent div's height is limited to the height of the screen because its height is set to 100%.
In my case, I've set the following properties:
html, body { width: 100%; height: 100%; }
.parent {
width: 100%;
height: 100%:
position: relative;
}
.child1 {
width: 100%;
height: 100%;
min-height: 520px;
max-height: 960px;
position: relative;
}
.child2 {
width: 100%;
height: 900px;
position: relative;
}
I can position a div inside of the second child to be absolutely positioned relative to the bottom of the second child, but I need to have overflow: hidden
set on the second child for other elements, and since the background size is supposed to scale with the width of the page, it gets clipped on large screens.
Example: http://jsfiddle.net/qxbu0mom/
edit:
Thanks to Terry for pointing out I can use vh; I can just change the first child's height to 100vh and remove height: 100%
from the parent.