Reputation: 1491
I have a div element that I want to move with the page for when you scroll it, such as in the picture below. but right now it's just sitting in a fixed position. How can I accomplish this? I know I need to use JS, can someone point me in the right direction ?
<div id='slider'>
</div>
Upvotes: 0
Views: 783
Reputation: 51441
You can always use fixed positioning in CSS without JavaScript.
#slider {
position: fixed;
top: 100px;
left: 0px;
}
Upvotes: 4
Reputation: 7971
I think your are looking for this kind of functionality. read out full documentation for how to use here
<script type="text/javascript">
jQuery(document).ready(function($) (
{
$('#floatdiv').addFloating(
{
targetRight: 10,
targetTop: 10,
snap: true
});
});
</script>
Upvotes: 1
Reputation: 606
There is no need for JS you should use position fixed
div#slider {
position: fixed;
}
Upvotes: 5