How to make Javascript Scroll less Jumpy
In my defense - I don't know Javascript amazingly.
Here's my webpage: www.andrewjalexander.com
Here's the code someone helped me to get:
window.onscroll = moveEle;
function moveEle() {
//Alter top to be how many pixels you want from the top of the window
var top = 100;
ele = document.getElementById('sidebar');
if(document.body && document.body.scrollTop) {
ele.style.top = (document.body.scrollTop + top) + "px";
} else if(document.documentElement && document.documentElement.scrollTop) {
ele.style.top = (document.documentElement.scrollTop + top) + "px";
}
}
The scrolling seems incredibly jumpy. I tried CSS but the sidebar kept overlapping with the main d开发者_JS百科iv.
Is there a way to get scrolling, and no overlap with any of the divs?
http://jsfiddle.net/myprg/3/
just added positon: fixed to
it's now <ul style ="position: fixed;">
it overlaps but it has to be a really small screen. still looks smooth.
精彩评论