I want to keep the position of an element likes a component on right side when I scroll down because of a very long content. Please take look at the code by visit the following link:
http://jsfiddle.net/p3unbmdy/
Javascript function:
http://jsfiddle.net/p3unbmdy/
Javascript function:
$("#container").bind('scroll', function() { var fromTop = 50; var scrollVal = $("#container").scrollTop(); var top = 0; if ( scrollVal > fromTop) { top = scrollVal - fromTop; $('#rightElement').css({'position':'absolute','right':'1em','top' :top+'px'}); } else { $('#rightElement').css({'position':'static','top':'0px'}); } });
Comments
Post a Comment