Only Enable Scrollbar on Body And Disable on Other Div with CSS HTML

橙三吉。 提交于 2019-12-31 03:55:08

问题


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.


回答1:


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/



来源:https://stackoverflow.com/questions/45892623/only-enable-scrollbar-on-body-and-disable-on-other-div-with-css-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!