只在身体上启用滚动条,并在CSS HTML上禁用其他Div [英] Only Enable Scrollbar on Body And Disable on Other Div with CSS HTML

查看:103
本文介绍了只在身体上启用滚动条,并在CSS HTML上禁用其他Div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这个代码在任何地方都禁用所有的滚动条:

有没有一种方法只在主体上启用滚动条并禁用其他div?
$ b

  ::  -  webkit-scrollbar {
display:none;
}

如何只在身体上启用?






EDITED



更改溢出不是我想要的。假设我想要创建移动友好视图编辑器,它能够在div内容中上下滚动,但滚动条应该隐藏。滚动条在正文中是必需的,因为我将不得不从我的桌面Web浏览器编辑视图。



在这种情况下更改溢出不会有帮助。

解决方案

这两个CSS属性可以用来隐藏滚动条:

  #parent {
height:100%;
宽度:100%;
overflow:hidden;
}

#child {
width:100%;
身高:100%;
overflow-y:scroll;
}

jsfiddle: http://jsfiddle.net/5GCsJ/954/


Is there a way to only enable scrollbar on the body only and disable on other divs?

This code disables all scrollbar in everywhere:

::-webkit-scrollbar {
    display:none;
}

How to enable only on the body?


EDITED

Changing overflow is not the one I want. Let's say I want to create mobile friendly view editor, which able to scroll up and down inside the div content but the scrollbar should be hidden. The scrollbar in the body is necessary because I will have to edit the view from my desktop web browser.

Changing overflow will not help in this case.

解决方案

These two CSS properties can be used to hide the scrollbars:

#parent{
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#child{
    width: 100%;
    height: 100%;
    overflow-y: scroll;
}

jsfiddle: http://jsfiddle.net/5GCsJ/954/

这篇关于只在身体上启用滚动条,并在CSS HTML上禁用其他Div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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