CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.
Can we scroll any div using percentage instead px?
Thanks in advance!
My first question would be why you want to do this — in which context do you need this to work?
var percent = .2;
var div = document.getElementById(“div”);
div.scrollTop = percent * (div.scrollHeight-div.clientHeight);
You must be logged in to reply to this topic.
Search for Stuff
Browse the Archives
Get the Newsletter
... or get the RSS feed