Question

Hello all,I'm a junior on html,I have a question about css position :

first here is my demo html code

<div id="test-header"></div>
<div id="test-content"></div>
<input type="button" value="body">

I set the "test-content" position: absolute,the "test-header" in default

but when I use $("body").height() to get the body's height,it only alert the "test-header"'s height ……

So why count would not include the abasolute element's height?

How can I solve this problem ?

here is my online case

Was it helpful?

Solution

This is the correct result, when you absolutely position an element it's taken out of the flow of the document, and doesn't occupy any space inside it's parent...which is why <body> doesn't account for the size it takes up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top