How to create custom scrollbar using jquery mcustomscrollbar plugin ?
In this post, we will learn how to make custom scrollbar will better layout using jquery.mcustomscrollbar plugin. We always want to make best layout of scrollbar instead of default browser layout. default browser layout scrollbar always deferent layout because it depend of browser. So today in this post you can see how to make pretty beautifully scrollbar using mcustomscrollbar plugin. mcustomscrollbar plugin provide us several other option to make more better like set theme and options.
So here i make very simple example using mcustomscrollbar cdn, you can see layout of example and also you can simply run bellow full example. So you can simply use mcustomscrollbar plugin with different theme like as bellow:
(function($){
$(window).on("load",function(){
$(".my-scroll").mCustomScrollbar({theme:"dark-3"});
});
})(jQuery);
Bellow you can see the preview of this example:
Preview:
Example:
<!DOCTYPE html>
<html>
<head>
<title>Custom Scrollbar Example</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.5/jquery.mCustomScrollbar.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.5/jquery.mCustomScrollbar.min.js"></script>
<style type="text/css">
.my-scroll{
border:1px solid #e1e1e1;
height: 200px;
width:400px;
overflow-y: auto;
}
</style>
</head>
<body>
<div class="container">
<br/>
<h2>Custom scrollbar using jquery mcustomscrollbar Plugin</h2>
<br/>
<div class="my-scroll">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
<script>
(function($){
$(window).on("load",function(){
$(".my-scroll").mCustomScrollbar({theme:"dark-3"});
});
})(jQuery);
</script>
</body>
</html>
I hope it can help you...

Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Bootstrap - Jquery multiple select with checkboxes example using bootstrap-multiselect.js plugin
- Twitter bootstrap - fancy alert box example and demo using SweetAlert Plugin
- Bootstrap Color Picker Example using mjolnic colorpicker plugin
- Jquery - Timepicker with AM PM Example code with demo using jQuery Timepicker Plugin
- Jquery notification popup box example using toastr JS plugin with demo
- Jquery - input tags plugin example using jquery.tagsinput.js plugin