jquery nicescroll

sao*_*omi 5 jquery jquery-plugins nicescroll

我正在使用 nicescroll 插件。http://areaaperta.com/nicescroll/

我只是有点怀疑。页面加载后,我可以从浏览器中看到默认滚动条,然后显示的是 nicescroll 条。我想将 nicescroll 栏应用于所有文档,我有以下代码

var nice = $("body").niceScroll({
        preservenativescrolling: false,
        cursorwidth: '8px',
        cursorborder: 'none',
        cursorborderradius:'0px',
        cursorcolor:"#39CCDB",
        autohidemode: false, 
        background:"#999999"
     });
Run Code Online (Sandbox Code Playgroud)

如果我将 autohidemode 设置为 true,我将看不到浏览器中的默认滚动条。但我想让 nicescroll 栏始终可见。

有谁知道为什么会这样??谢谢

Rok*_*jan 0

我的第一个想法是让你的类.nicescroll元素overflow:hidden;在你的CSS中,这样滚动条就不会出现,

比在文档加载后(最好是在 window.load 上)应用 NiceScroll 插件并overflow:auto使用 jQuery 设置元素,如下所示:

CSS:

.nicescroll{overflow:hidden;}
Run Code Online (Sandbox Code Playgroud)

jQuery:

$(window).load(function(){
   $('.nicescroll').css({overflow:'auto'});
});
Run Code Online (Sandbox Code Playgroud)

我认为在您的情况下,您必须向body元素添加 ID 或类(如我的示例中所示)。