1、引入CSS
<link rel="stylesheet" href="css/mCustomScrollbar.css" />
2、引用Js文件
<script src="js/jquery.min.js"></script>
<script src="js/mCustomScrollbar.js"></script>
3、初始化插件(需保证使用盒子溢出块的典型CSS属性)
Js:
<script>
(function($){
$(window).on("load",function(){
$(".content").mCustomScrollbar();//content为需要增加滚动条的class
});
})(jQuery);
</script>
样式(直接给需要的盒子添加mCustomScrollbar类):
<div class="mCustomScrollbar" data-mcs-theme="dark">
<!-- your content -->
</div>
注意:可能会出现checkVisible()方法错误
解决:添加该方法
function checkVisible(){
}