我正在寻找一个与在这里输入链接描述一样的概念显示行星间相对距离的网页。我不知道这是一个预先制作好的jquery插件还是定制的。提亚
发布于 2017-03-11 03:48:10
你主要需要两件事:
然后,这取决于您如何实现它,但以下内容如下:
window.onscroll = function() {
var px = document.getElementById('px');
px.innerText = window.scrollY;
} main {
height: 5000px;
}
#counter {
position: fixed;
top: 0;
right: 0;
width: 200px;
height: 2em;
border: 1px solid #000;
}<div id="counter">
You are <span id="px">0</span>px down!
</div>
<main>
Keep scrolling down!
</main>
发布于 2017-03-11 03:43:48
发布于 2017-03-11 03:48:12
您可以监听窗口“滚动”更改事件。
window.addEventListener('scroll',function(event){
console.log(window.scrollY); // for vertical scrolling
console.log(window.scrollX); // for horizontal scrolling
})
https://stackoverflow.com/questions/42731038
复制相似问题