0
参考线:Div at the browser bottom对齐的div底部
问题图片: http://i.imgur.com/I9vVv.png http://i.stack.imgur.com/jTU5U.png
我用所有的方法,这一切在WAIN去了。如果即使页面滚动,Jquery中是否还有任何方法可以将div放在底部?
由于提前
参考线:Div at the browser bottom对齐的div底部
问题图片: http://i.imgur.com/I9vVv.png http://i.stack.imgur.com/jTU5U.png
我用所有的方法,这一切在WAIN去了。如果即使页面滚动,Jquery中是否还有任何方法可以将div放在底部?
由于提前
对于除IE6其他浏览器,使用position: fixed
是不够的:
#footer {
position: fixed !important; /* IE6 hack */
position: absolute;
right: 0;
bottom: 0;
background: yellow;
}
对于IE6,一般的做法是注册scroll
事件和动态改变的top
样式属性#footer
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';
}
);
}
所以,你再次问了这个问题。给出最多点的答案是正确的答案。现在..我会非常建议你使用互联网浏览器的开发者工具,只是他们很蹩脚......你应该得到firefox和firebug,并检查你想要坚持在底部的那个元素。增强是它有一些其他的CSS给它的位置:绝对原因就是它的行为方式。 http://jsfiddle.net/lollero/JEW3V/ < - 尝试用你的方式前进。 – Joonas 2012-03-27 06:24:12