最佳答案
来自 perfectscrollbar wiki:
How can I make the scrollbars always visible?
The reason why it's hidden by default is that opacity: 0 is used. Please change all references of it to opacity: 0.6. If using .scss, modify the line @include opacity(0) to @include opacity(0.6) in the scrollbar-rail-default mixin and run gulp build to build .css and .min.css files.
If you're not willing to modify the CSS files but would like to make it always visible, please add following lines anywhere after perfect-scrollbar.css is loaded.
.ps-container > .ps-scrollbar-x-rail, .ps-container > .ps-scrollbar-y-rail { opacity: 0.6; }
Also, an example code may be helpful to see how to achieve it.
这是例子 https://github.com/noraesae/perfect-scrollbar/blob/master/examples/always-visible.html
因此,如果您通过将以下内容粘贴到您的 html 中来修改您的 JSFiddle,它就可以工作。
<div class="container">
<div class="content"></div>
</div>
<style>
.ps-container > .ps-scrollbar-x-rail,
.ps-container > .ps-scrollbar-y-rail { opacity: 0.6; }
</style>
关于javascript - 使完美的滚动条默认可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40548772/