javascript - 使完美的滚动条默认可见

标签 javascript jquery css custom-scrolling

我正在为自定义滚动条使用完美滚动条。它工作正常。

但滚动条只有当您将鼠标悬停在容器上时才可见。

如何使它始终可见?

$('.container').perfectScrollbar();

Demo

最佳答案

来自 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/

相关文章:

javascript - Node.js 服务器无法在 Windows 7 64 位上启动

Javascript:正则表达式删除 .html

javascript - 有没有办法在文本输入上应用默认的 "disabled"样式而不实际禁用输入?

javascript - 如何在表格列中显示一个按钮元素

javascript - javaScript, CSS , HTML , jQuery 测试工具

javascript - jScrollPane 在元素拖动时滚动

javascript - 文本框中仅允许基于连续 ID 的数字

javascript - 手动触发日期选择器 onselect 事件

html - 在 html 中嵌入 swf 文件高度/宽度

javascript - 需要帮助来限制游戏中生成的方 block 数量和目标数量