Get scroll in Chrome

For some reason, I have these CSS styles:

body { bottom: 0; height: 100%; overflow: auto; position: absolute; top: 0; width: 100%; } html { overflow: hidden; } 

In Firefox: $ ('body'). scrollTop () = 743; But in Chrome: $ ('body'). ScrollTop () = 0;

The JsFiddle for testing is here: http://jsfiddle.net/uFCCU/

How to get scrollTop from "body" in webkit browsers?

+1
javascript html css
source share
2 answers

I can’t understand exactly why it doesn’t work with the CSS that you have, but if you change your CSS to

 body, html { height: 100%; width: 100%; } 

Then $(document).scrollTop() gives you the correct values ​​in FF and chrome http://jsfiddle.net/uFCCU/1/

It has the same effect from what you tried to do (I think), and does nothing strange, how to make the body absolutely positioned. I have never seen this in 15 years of web development.

0
source share

I'm not sure what you are trying to do, but the style for html actually exists, except for messing up webkit .

 html { overflow: hidden; } 

Just delete it.

0
source share

All Articles