SimpleBar是一个简单的、独立的JavaScript库,添加一个自定义滚动条滚动容器已满溢的内容,使用方法很简单。
(下载的附件中附有DEMO)
1. 引入文件
<link rel="stylesheet" href="https://unpkg.com/simplebar@latest/dist/simplebar.css" />
<script src="https://unpkg.com/simplebar@latest/dist/simplebar.js"></script>
<!-- or -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/simplebar@latest/dist/simplebar.css">
<script src="https://cdn.jsdelivr.net/npm/simplebar@latest/dist/simplebar.js"></script>
<div data-simplebar></div>
初试化:
new SimpleBar(document.getElementById('myElement'));
or
Array.from(document.querySelectorAll('.myElements')).forEach(el => new SimpleBar);
JQuery方式使用:
new SimpleBar($('#myElement')[0]);
or
$('.myElements').each(element, new SimpleBar);
GitHub 地址 :https://github.com/marcoarib/simplebar
官方文档:https://grsmto.github.io/simplebar/
在线演示:http://www.bootstrapmb.com/item/12254/preview