在移动设备上不活跃滚动时无法隐藏滚动条

时间:2020-07-19 21:11:13

标签: css

enter image description here

这在台式机上完全可以正常工作:

{
  window.location.pathname.slice(1) === "blogs" && <Blogs {...props} setLoad={() => loading()} />
  window.location.pathname.slice(1) === "competition" && <Competition {...props} setLoad={() => loading()} /> 
  window.location.pathname.slice(1) === "extrapages" && <ExtraPage />
}

.container::-webkit-scrollbar { width: 5px; } .container::-webkit-scrollbar-track { background: none; } .container::-webkit-scrollbar-thumb { background: #f5f5f573; border-radius: 50px; visibility: hidden; } .container::-webkit-scrollbar-thumb:hover { background: #555; } .container:hover::-webkit-scrollbar-thumb { visibility: visible; } 是颜色按钮的容器。问题在于它不会在移动设备上消失。有什么办法可以使移动设备上的滚动条不滚动消失?

2 个答案:

答案 0 :(得分:0)

我认为这种方式只会隐藏chrome和某些其他浏览器的滚动条,但可能不适用于其他浏览器。 我建议您看一下这个StackOverflow问题:Hide scroll bar, but while still being able to scroll

答案 1 :(得分:0)

html {
    overflow: scroll;
    overflow-x: hidden;
}
::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}