javascript - Hiding scroll bar causes the body to scroll up -


i've noticed if trying hide scroll bar using overflow:hidden scrolls site top if css style used html , body elements:

html,body {     height: 100%; } 

this jquery code used:

$('#end').click(function(){         $("html, body").css("overflow", "hidden"); }); 

living demo: http://jsfiddle.net/hyngn/

this happens in major browsers: chrome, firefox, ie9, opera...

how can avoid behavior?

thanks.

the body has height: 100% children nodes make him overflow. when set overflow hidden result body height: 100% relative window looks scroll.

you can keep height, don't see point of doing this, , it's bugs scrollbar on chrome/chromium

$("html, body").css({     "overflow": "hidden",     "height": "auto" }); 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -