我正在尝试学习这个叫做Simplebar的很酷的插件,但是我不能让它显示在一个演示页面上。我遗漏了什么?
根据https://github.com/Grsmto/simplebar的说法,我只需要引用simplebar.css和脚本,然后将"data-simplebar“添加到我希望可以滚动的任何div中。
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="https://unpkg.com/simplebar@latest/dist/simplebar.min.css">
</head>
<body>
<div data-simplebar style="background-color: grey; width: 400px;">
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
</div>
</body>
<script src="https://unpkg.com/simplebar@latest/dist/simplebar.js"></script>
</html>
发布于 2019-01-04 22:16:19
将高度添加到div以解决此问题:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="https://unpkg.com/simplebar@latest/dist/simplebar.min.css">
</head>
<body>
<div data-simplebar style="background-color: grey; width: 400px;height:300px;">
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
<p>My first paragraph.</p>
</div>
<script src="https://unpkg.com/simplebar@latest/dist/simplebar.js"> </script>
</body>
</html>`https://stackoverflow.com/questions/54040592
复制相似问题