我正在尝试在网站上创建一种效果,其中使用以下 CSS 将元素固定到浏览器底部:
div.featured-image {
width: 100%;
position: fixed;
z-index: 10;
}
我想要发生的事情是使用类似 http://vertstudios.com/blog/demo/stickyscroller/demo.php 停止项目滚动 UP< /b>超过某一点。我在网站顶部放置了一个绝对定位的徽标,并且如果浏览器不够高,则不希望固定项目与它重叠。所以我试图让它无法滚动超过顶部大约 800px 的缓冲区,但仍然固定在页面底部。
I'm trying to create an effect on a website where an element is fixed to the bottom of the browser using the following CSS:
div.featured-image {
width: 100%;
position: fixed;
z-index: 10;
}
and what I want to happen is to use something like this http://vertstudios.com/blog/demo/stickyscroller/demo.php to stop the item from scrolling UP past a certain point. I have a logo placed at the top of the site positioned absolutely, and don't want the fixed item to overlap it if the browser is not tall enough. So I'm trying to get it to not be able to scroll past a buffer of around 800px at the top, but still stay fixed at the bottom of the page.
发布评论
评论(1)
您可以使用 JQuery 并基于
scrollTop()
动态设置/重置元素的顶部和底部css
属性来实现此目的。示例 JQuery:
CSS(用于 div#footer):
以及一个可用的 fiddle。
You could do this with JQuery and dynamically setting/resetting the top and bottom
css
properties of the element based on ascrollTop()
.Sample JQuery:
CSS (for div#footer):
And a working fiddle.