I am using the below code to make a DIV always at the bottom of the page when scrolled. But this is not working and goes on increasing the Page height.
var LSscrollingDiv = $("#LightSwitchMenuIt");
$(window).scroll(function(){
LSscrollingDiv
.stop()
.animate({"marginTop": ($(window).scrollTop() + $(window).height()) + "px"}, "slow" );
});
Please help me on this.
Use position fixed. Position fixed makes it so that an element stays at it's specified place even if the user scrolls up or down.
To place a div in bottom right corner of browser or iframe, we can use position:fixed along with right and bottom property value assigned to 0.
Why not use straight CSS?
div.foo {
position: fixed;
bottom: 0px;
}
Demo.
See:
This might be a simple CSS issue ... you can place a DIV to a fixed position at the bottom of the viewport and it will always be there when scrolling, without any Javascript
position: fixed;
bottom: 0px;
You can use css
position: fixed;
bottom: 0;
to avoid having to do this in javascript if you like.
http://jsfiddle.net/A8BGJ/ is a simple demonstration.
It may help to have width set as inherit too.
#div {
position: fixed;
bottom: 0;
width: inherit;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With