选择/拖动文本时停止页面滚动
我有一个页面,我不希望用户能够滚动。为了防止这种情况,我只是将主体设置为隐藏溢出样式。直到用户尝试选择一些文本然后拖动到底部为止,这已经足够了。然后窗口会随着用户的拖动而滚动。我怎样才能防止这种情况发生?
I have a page where I do not want the user to be able to scroll. In order to prevent it, I just set the body to have a hidden overflow style. This is sufficient up until the point where a user tries to select some text and then drags to the bottom. The window then scrolls with the users dragging. How can I prevent this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
位置:固定;
。如果您希望整个正文不可滚动:编辑:收到用户 Sam 的评论后,我决定返回并再次测试此方法。现在我重新考虑它,Sam 担心它会扰乱样式,我得出的结论是,以下将是一个更好的解决方案:
防止某些网站(包括 stackoverflow)最终左对齐。它还使用可用的最高节点,这应该首先完成。
use
position: fixed;
. If you want the whole body to be non-scrollable:EDIT: after receiving the comment from user Sam, I've decided to go back and test this method once again. Now that I reconsider it and Sam's concern that it would mess with styles, I've come to the conclusion that the following would be a better solution:
The prevents some sites (stackoverflow included) from ending up left aligned. It also uses the highest node available, which should have been done in the first place.
我尝试了约瑟夫的回答,但它可能会弄乱网站上的很多风格。
另一种方法是将网站的溢出设置为隐藏,这也远非理想,但它并没有搞乱我的任何样式,希望这对某人有帮助。
I tried Josephs answer but it can mess up a lot of the style on the website.
Another way would be to set the overflow of the website to hidden, this is also far from ideal but it didn't mess up any styling for me, hopefully this is helpful to someone.
这可能会有帮助
It can be helpfull