what am i missing in the following code? Why is Perfect scrollbar horribly crashing?
It seems it's messing up myDiv scrollbar with browser main scrollbar... any help is appreciated.
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta charset="utf-8" />
<link href="perfect-scrollbar.min.css" type="text/css" rel="stylesheet">
<style>
#myDiv {
width: 400px;
height: 400px;
overflow: auto;
background-color: #eeeeee;
margin: auto;
}
</style>
</head>
<body>
<div id="myDiv">
<p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p><p>Test perfect scrollbar</p>
</div>
<script type="text/javascript" src="jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="perfect-scrollbar.jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#myDiv').perfectScrollbar();
});
</script>
</body>
</html>
Thank you
Add position:relative
to #myDiv
Demo: https://jsfiddle.net/gbfLazpx/243/
CSS:
#myDiv {
width: 400px;
height: 400px;
overflow: auto;
background-color: #eeeeee;
margin: auto;
position: relative;
}
Check the first point here: https://github.com/noraesae/perfect-scrollbar#requirements
the container must have a 'position' css style.