禁用主体滚动,但将其保留在高度大于浏览器的各个div元素 [英] Disable the body scroll, but keep it on individual div elements which are greater in height than the browser

查看:122
本文介绍了禁用主体滚动,但将其保留在高度大于浏览器的各个div元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了所有地方,还没有得到解决方案。好吧,这个交易,我有一个单页网站,其中有几个div元素在下面,有点像个人页面我猜。我想要实现的是禁用实际网页的滚动一起,但保持活动div的滚动在播放,如果它低于Web浏览器。要通过在页眉上使用锚链接来简单完成页面的其他部分。

I have searched everywhere and have yet to get a solution. Okay heres the deal, I have a one page website which has several div elements underneath each other, sort of acting like individual pages I guess. What I want to achieve is to disable the scrolling of the actual web page all together, yet keeping the scroll of the active div in play if it goes below the web browser. To get to each other section of the page is simple done by using anchor links on the header.

推荐答案

肯定你在找什么,但我想你想要一个div是可滚动的,但不是实际的文档。您可以通过在屏幕上以固定高度绝对定位div并将 overflow 设置为 auto 来实现。我使用下面的CSS代码:

I'm not exactly sure what you're looking for, but I think you want a div to be scrollable, but not the actual document. You can do this by absolutely positioning the div on the screen with a fixed height and set the overflow to auto. I've done this using the following CSS code:

#scrollable {
    position: absolute;
    top: 10px;
    right: 10px;
    bottom: 10px;
    left: 10px;
    overflow: auto;
}​

查看示例: http://jsfiddle.net/rustyjeans/rgzBE/

这篇关于禁用主体滚动,但将其保留在高度大于浏览器的各个div元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆