如果你需要把它作为这个
jQuery保持在底部使用
$(document).scroll(function() {
var objectTop = $('#shopping-cart').position().top;
var objectHeight = $('#shopping-cart').outerHeight();
var windowScrollTop = $(window).scrollTop();
var windowHeight = $(window).height();
if((objectTop+objectHeight) <= $('html').outerHeight())
$('#'+cont).css('top', (windowScrollTop+windowHeight)- objectHeight);
else
$('#'+cont).css('top', $('html').outerHeight()- objectHeight);
});
CSS
#shopping-cart{
width: 100%;
height: 50px;
position: absolute;
left: 0px;
bottom: 0px;
}
如果您需要将其作为此
jquery使用
$(document).scroll(function() {
var objectHeight = $('#shopping-cart').outerHeight();
var windowScrollTop = $(window).scrollTop();
var windowHeight = $(window).height();
$('#shopping-cart').css('top', windowScrollTop );
});
CSS
#shopping-cart{
width: 100%;
height: 50px;
position: absolute;
left: 0px;
top: 0px;
}
它会发挥魔力,不要忘记保持你的风格与位置,一件事它不适用于 Internet Explorer 8.0.7