本文介绍了滚动页面时更改图层位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改页面滚动上的图层.
I want to change a layer on page scroll.
推荐答案
window.onscroll = function() {
var layer = document.getElementById('dvDynamicPostion');
layer.innerHTML += "\nscroll is at " + document.body.scrollLeft + " horizontally and " + document.body.scrollTop + " vertically.";
layer.style.position = 'absolute';
layer.style.top = '10px'; //Top position: You can change according your login
layer.style.left = '10px'; //Left position: You can change according your login
}
HTML代码
HTML code
<div id="dvDynamicPostion">
my position are always changed
</div>
如有任何疑问,请让我知道.
如果有帮助,请提供"投票",如果这是正确的答案,请提供"接受答案".:rose:
谢谢,
Imdadhusen
Please do let me know, if you have any doubt.
Please provide "Vote" if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:
Thanks,
Imdadhusen
这篇关于滚动页面时更改图层位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!