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 created fiddle here

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

https://jsfiddle.net/wzzopxte/5/


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -