如何隐藏滚动条而不使用溢出“隐藏”?

时间:2018-06-13 09:21:04

标签: html css

image1的

enter image description here

在此图片中,没有滚动条,但如果我向下滚动图表组件div元素滚动条将会出现

带滚动条的

image2

enter image description here

如何在不设置overflow: hidden

的情况下隐藏滚动条

引用

enter image description here

enter image description here

2 个答案:

答案 0 :(得分:1)

只需使用它的CSS:

selector-with-overflow::-webkit-scrollbar {
    width: 10px;
    visibility: hidden;
    display: none;
}

通知并不适用于所有浏览器,但应该适用于最常见的浏览器

答案 1 :(得分:0)

我不确定你为什么要隐藏页面溢出的迹象,请参阅此JSFiddle:http://jsfiddle.net/2nT38/868/以获取css的滚动条,该滚动条仍然无法显示滚动。这是细分:

::-webkit-scrollbar {
    -webkit-appearance: none;
}
::-webkit-scrollbar:vertical {
    width: 0px;
}
::-webkit-scrollbar:horizontal {
    height: 0px;
}

希望这有帮助!