Question

I've got this Fiddle. http://jsfiddle.net/QF47A/3/

Well, I tried a similar code on my website, it worked great until I added a doctype. Then the code would always return the top from 0px.

Well take a look: on JsFiddle. It starts from 0, and the ascends to negative numbers.

Was it helpful?

Solution

When you add position:absolute; to any element in the DOM (in english) it gives up it's space just like float does. there isn't a way around this unless you add the height to the body.

Basically body doesn't know that #fly is there so body has no height.

If you remove position:absolute; you will see

document.height will work for you in this case

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