Reputation: 1897
Okay, so there's three ways to get browser window height (NOT full web page height, that is the difference).
I do not understand the logic behind #3 on my list.
height: 100%
and absolute
positioning. height: 100%
fills up the parent. Positioning absolute
also is relative to the parent, so shouldn't it take the full height of the page. How does the viewport come into play?
I know that fixed
is relative to the viewport, but I thought that was the difference from absolute
. The height: 100%
div does have a parent, its the body
, it should be relative to that.
Can someone please explain?
Upvotes: 3
Views: 92
Reputation: 15158
An absolutely positioned element is placed in relation to the first parent that is also positioned. The body element has no positioning applied to it in your example. Therefore, the div has no reference since absolutely positioned elements are taken out of the normal flow.
If you assign positioning to the body, typically position:relative;
, you will find what you are looking for.
Upvotes: 1