【发布时间】:2021-12-28 15:20:18
【问题描述】:
我想让滚动条在用户不滚动内容时也可见。
代码如下:
div{
width:200px;
height:200px;
overflow:scroll;
}
div::-webkit-scrollbar{
visibility: visible;
}
<div>Wikipedia is an online free-content encyclopedia project helping create a world in which everyone can freely share in the sum of all knowledge. It is supported by the Wikimedia Foundation and is based on a model of freely editable content. The name "Wikipedia" is a blending of the words wiki (a technology for creating collaborative websites, from the Hawaiian word wiki, meaning "quick") and encyclopedia. Wikipedia's articles provide links designed to guide the user to related pages with additional information.</div>
visibility: visible; 以使滚动条在我滚动时仍然可见,但似乎不起作用。
有什么方法可以做到吗?
如果没有,我可以通过自定义滚动条使其可见吗?
【问题讨论】:
-
嗨,实现这一目标的最简单方法是将您的
overflow: scroll属性封装在父 div 上。 -
@Blazorman ^ 不会使滚动条始终可见。这就是他已经拥有的。