Javascript 在浏览器底部对齐div
请参阅以下线程: 问题图像: 我用了所有的方法,一切都进展顺利。Jquery中是否有任何方法可以在页面滚动时在底部放置divJavascript 在浏览器底部对齐div,javascript,jquery,Javascript,Jquery,请参阅以下线程: 问题图像: 我用了所有的方法,一切都进展顺利。Jquery中是否有任何方法可以在页面滚动时在底部放置div 提前感谢对于IE6以外的浏览器,使用位置:fixed就足够了: #footer { position: fixed !important; /* IE6 hack */ position: absolute; right: 0; bottom: 0; background: yellow; } 对于IE6,一般的方法是注册
提前感谢对于IE6以外的浏览器,使用
位置:fixed
就足够了:
#footer {
position: fixed !important; /* IE6 hack */
position: absolute;
right: 0;
bottom: 0;
background: yellow;
}
对于IE6,一般的方法是注册滚动
事件,并动态更改页脚
的顶部
样式属性
var footer = document.getElementById('footer');
// Test IE6
if (footer.currentStyle &&
footer.currentStyle.position !== 'fixed') {
// Set bottom to 'auto' because we would use top property
footer.style.bottom = 'auto';
// Only for IE6, so use window.attachEvent
window.attachEvent(
'onscroll',
function() {
var scrollTop = document.documentElement.scrollTop;
var pageHeight = document.documentElement.offsetHeight;
var height = footer.offsetHeight;
footer.style.top = (scrollTop + pageHeight - height) + 'px';
}
);
}
那么,你又问了这个问题。得到最多分数的答案是正确的。现在。。我非常建议你使用InternetExplorers开发工具,只是它们非常糟糕。。。你应该得到firefox和firebug,并检查你试图粘在底部的元素。很可能它有一些其他css使它处于
位置:绝对,因为这就是它的行为方式。