网站链接:http://www.bigideaadv.com/xsp
我正在尝试让页脚固定下来。在 Firefox 中工作正常,在 IE 和 Safari/Chrome 中不是这样。当窗口变得太小时,页脚会从固定位置切换到应该位于页面底部的更流畅的位置。
如果您缩短窗口然后滚动到页面底部,然后展开页面直到滚动条结束,页脚位于页面底部上方约 50-100 像素。有谁知道为什么会这样?
CSS:
html, body {
width: 100%;
height: 100%;
}
#wrap {
min-height:100% !important;
}
#wrap:before { /* Opera and IE8 "redraw" bug fix */
content:"";
float:left;
height:100%;
margin-top:-999em;
}
#container {
position: relative;
/*margin: 72px 0 172px 0;*/
top: 72px;
bottom: 172px;
width: 100%;
height: auto;
overflow: auto;
}
#top_navigation {
position: fixed;
min-width: 1010px;
width: 100%;
height: 72px;
background: url('../images/opaque.png') repeat;
text-transform: uppercase;
z-index: 2000;
}
#bottom_navigation {
position: fixed;
min-width: 1550px;
width: 100%;
height: 172px;
background: url('../images/opaque.png') repeat;
text-transform: uppercase;
}
Javascript:
int_window_width = $(window).width();
int_window_height = $(window).height();
if ((int_window_width <= int_min_window_width && int_window_height >= int_min_window_height) || int_window_height <= int_min_window_height) {
$('html').css('overflow-y', 'scroll');
$('#bottom_navigation').css('bottom', '');
$('#bottom_navigation').css('margin-top', '');
$('#bottom_navigation').css('position', 'relative');
}
if ((int_window_width >= int_min_window_width && int_window_height >= int_min_window_height) || int_window_height >= int_min_window_height) {
$('html').css('overflow-y', 'hidden');
$('#bottom_navigation').css('position', 'absolute');
$('#bottom_navigation').css('top', '');
$('#bottom_navigation').css('bottom', '0');
$('#bottom_navigation').css('margin-top', '');
}
最佳答案
如果您希望页脚在文档滚动时不移动,只需使用 position:fixed;底部:0
。 IE6 不支持 position:fixed
所以你需要应用一个 polyfill:http://www.css-101.org/fixed-positioning/05.php
关于jquery - 粘性页脚不粘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9624812/