我使用javascript让侧边栏在页面滚动时保持可见。只有当页面滚动到其容器的顶部时,侧栏才会变得固定。代码如下:
<script>
function moveScroller() {
var a = function() {
var b = $(window).scrollTop();
var d = $("#featured-scroller-anchor").offset({scroll:false}).top;
var c=$("#featured-scroller-content");
if (b>d) {
c.css({position:"fixed",top:"5px"})
} else {
if (b<=d) {
c.css({position:"relative",top:""})
}
}
};
$(window).scroll(a);a()
}
</script>这很好用,除了我还在页面底部有一个页脚,我想让它在侧边栏前面可见。目前,侧边栏显示在页脚上方,我不知道如何更改它。
我有一个z-index为999的页脚,我试着将#featured scroller content的z-index设置为更小的值,但没有起作用。唯一有效的方法是将侧边栏的z-index设置为-1,但之后侧边栏中的所有链接都不再有效。
发布于 2011-09-01 07:51:15
页脚是否有position: relative
https://stackoverflow.com/questions/7264753
复制相似问题