jquery - Fixing position on DIV while page scrolls -
i have page 2 columns. left column quite longer right one.
when start scrolling i'd right column stay left column moves.
this means right column visible when page scrolled.
i thought needed set div position:fixed;
works moves right div sits on left.
how do right div stays in place?
i've looked @ using jquery animate scrolling, didn't work either..
$(window).scroll(function(){ $("#right").stop().animate({"margintop": ($(window).scrolltop()) + "px", "marginleft":($(window).scrollleft()) + "px"}, "slow" ); });
you need add position: fixed
on #right
div
css
#right { width: auto; float: right; top: 40px; background-color: #eee; border: 1px solid #aaaaaa; position: fixed; }
demo
Comments
Post a Comment