简体   繁体   English

如何使滚轮滚动距离达到页面高度的100%?

[英]How can I make the wheel scrolling distance 100% of page height?

Hey guys I have a page and I'm trying to capture the mouse wheel so when someone is at the top and scrolls just once the page scrolls to the 100% of what the browser shows sorry I have no idea how to explain this just visit Mega and scroll down once and you will see what I mean. 嘿,我有一个页面,我试图捕获鼠标滚轮,所以当有人在顶部并滚动时,页面滚动到浏览器显示的内容的100%,对不起,我不知道如何解释这一点Mega ,向下滚动一次,您会明白我的意思。 Thanks for any tips :) 感谢您的提示:)

Not a complete implementation, by any stretch, but should be enough to get you started. 无论如何,这都不是一个完整的实现,但是应该足以使您入门。

HTML 的HTML

<div id="head">Your top page...</div>
<div>All other content...</div>

CSS 的CSS

#head {
  height: 100vh;
}

Javascript Java脚本

var head = document.getElementById('head');
head.addEventListener("wheel", handleMouseWheel);

function handleMouseWheel (event) {
  window.scrollTo(0, head.scrollHeight);
}

See working http://codepen.io/jtrumbull/pen/vXNREy 参见工作http://codepen.io/jtrumbull/pen/vXNREy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM