强制div元素保持在相同的位置,当页面滚动 [英] Force div element to stay in same place, when page is scrolled
本文介绍了强制div元素保持在相同的位置,当页面滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个 div
元素,我一直放在我的网站的右边。唯一的问题是它在网站的顶部,所以如果我向下滚动它仍然在那里。
如何强制它保持在同一部分的页面,当页面正在滚动?
这是,我已经设法弄清楚自己到目前为止:
< div style =width:200px; background-color:#999; z-index:10; position:absolute; right:0; top:0; height:83px ;>
< / div>
更改 position:absolute
到 position:fixed;
。
I created a div
element, that I placed all the way on the right of my site. The only problem is that its at the top of the site, so if i scroll down it remains there.
How can I force it to remain in the same part of the page, when page is being scrolled?
This is, what I've managed to figure out myself so far:
<div style="width: 200px; background-color: #999; z-index: 10; position: absolute; right: 0; top: 0; height: 83px;">
</div>
解决方案 Change position:absolute
to position:fixed;
.
Example can be found in this jsFiddle.
这篇关于强制div元素保持在相同的位置,当页面滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文