为什么我的自定义滚动条没有显示在浏览器中?

时间:2017-01-20 01:18:56

标签: javascript html css jquery-plugins scrollbar

以下jQuery代码在Dreamweaver实时视图中提供了良好的结果,但在浏览器或提琴手中不起作用:



(function($){
  $(document).ready(function(){
    $('.text-scroller1').each(function () {
      var $this = $(this);
      // field_category width bugfix
      /*if ($this.attr('name').indexOf('field_category') != -1) {
              var delta = 5;
            }
            else {
              var delta = 15;
            }*/
      var delta = 15;
      var width = $this.parent().width() - $this.parent().find('label').width() - delta;
      
    });

    $('.text-scroller1').mCustomScrollbar({
        axis: "y",
        theme: "dark"
      });
    });


})(jQuery);

.text-scroller1 {
	display: inline-block;
	padding: 5px;
	margin: 5px;
	position: relative;
	width: 100%;
	height: 30vh;
	overflow: auto;
	-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;

}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script src="https://github.com/malihu/malihu-custom-scrollbar-plugin/blob/master/jquery.mCustomScrollbar.concat.min.js" type="text/javascript"></script>

<link href="https://github.com/malihu/malihu-custom-scrollbar-plugin/blob/master/jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css">

<body>
<div class="text-scroller1 mCustomScrollbar">
     Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. 
    </div>
  

</body>
&#13;
&#13;
&#13;

我试图实现这个: http://manos.malihu.gr/jquery-custom-content-scroller/

我怎样才能让它发挥作用? 非常感谢!

1 个答案:

答案 0 :(得分:0)

jquery.mCustomScrollbar.concat.min.jsjquery.mCustomScrollbar.concat.css的链接似乎不正确。

尝试使用

https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.5/jquery.mCustomScrollbar.min.js

https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.5/jquery.mCustomScrollbar.min.css