::-webkit-scrollbar{
height:0px
width:0px;
}
// hides both vertical and horizontal scrollbar
如何仅隐藏垂直或水平滚动条?保留滚动功能,只隐藏其中一种方向。
我想隐藏垂直滚动条,但仍需保留滚动功能,overflow-hidden 会禁用整个滚动条。
::-webkit-scrollbar{
height:0px
width:0px;
}
// hides both vertical and horizontal scrollbar
html {
scrollbar-width: none; /* For Firefox */
-ms-overflow-style: none; /* For Internet Explorer and Edge */
}
html::-webkit-scrollbar {
width: 0px; /* For Chrome, Safari, and Opera */
}
html
可以替换为您想要隐藏滚动条的任何元素。
width
值是用于垂直条的。height
值是用于水平条的。 - Bruno Freire-webkit-scrollbar
中,width
的值是指垂直滚动条的宽度,height
的值是指水平滚动条的高度。html::-webkit-scrollbar {
width: 5px;
height: 0px; /* If value is 0px, the horizontal bar will disappear but still works*/
}
针对垂直滚动隐藏和水平滚动自动:
overflow: hidden;
overflow-x: auto;
如果要隐藏水平滚动条,垂直滚动条自动出现:
overflow: hidden;
overflow-y: auto;
overflow-x: hidden;
(隐藏水平滚动条)或overflow-y: hidden;
吗? - I like eating pizza thursdays