使用jquery nicescroll时水平滚动条问题

时间:2015-04-07 11:27:16

标签: jquery html css jquery-plugins nicescroll

我正在使用nicescroll jquery插件。 http://areaaperta.com/nicescroll/ 我得到了不需要的水平滚动条。通过执行此操作 horizrailenabled:false ,它会消失,但在重新调整窗口大小后它不会出现。它也禁用了重新调整尺寸,这也是我不想要的。我尝试了所有我的CSS也可能导致水平条出现,但没有任何事情发生,因为我想要。我猜它可能是由于宽度问题。但无法弄清楚。

如何让这个水平条消失?

我的代码到目前为止:

    <style>
body {
    margin:0;
    padding:0;
    color:#000;
    background:#FFFFFF;
    letter-spacing:0.5px;
    overflow-x:hidden;
}
        .wrap{
            background-color: #087877;
            height: 100%;
            overflow: hidden;
            position: relative;
            width:100% !important;
        }
        #scrollingContent{
            padding-left: 149px;
            padding-top: 136px;
        }
        #mainContent {
            position:absolute;
            padding:0;
            top:0;
            left:0;
            width:100%;
            height:100%;
            font-family:mainFont;
            color:#FFF;
            overflow:hidden;
        }
    .contactHeader{
        color: white;
        font: 100 52px/60px 'TitilliumText25L1wt',Arial,sans-serif;
        height: 125px;
        left: 144px;
        letter-spacing: 0;
        position: absolute;
        top: 0;
        width: 100%;
        z-index: 10;
        background-color: #178895;
        line-height: 142px;
    }
        </style>

        <div id="mainContent">
            <div id="newsWrapper" class="wrap">
                <div id="scrollingContent">
                <div class="newsHeader">news</div>
                                                           //content
               </div>
            </div> 
        </div>

        <script type="text/javascript">
             $("#newsWrapper").niceScroll({touchbehavior:false,cursorborder:"0px solid #fff",cursorcolor:"#E1F3FF",cursoropacitymax:0.2,cursorborderradius:0,bouncescroll:true,scrollspeed:100, cursorwidth:15,autohidemode:false,zindex:10});
             $("#newsWrapper").getNiceScroll().onResize()
        </script>

2 个答案:

答案 0 :(得分:0)

避免不必要的滚动添加css。为了避免在你的身体标签中不必要的滚动,请执行此操作。

body{
overflow-x: hidden;  /*avoiding horizontal scrolling*/
}

答案 1 :(得分:0)

您可以使用:

$("#newsWrapper").niceScroll({horizrailenabled:false});

了解更多信息:https://github.com/inuyaksa/jquery.nicescroll/issues/114

相关问题