To create custom scrollbars using jQuery, you can use the jQuery custom scrollbar plugin. Here are the steps to implement it:
1. Include the jQuery library and the custom scrollbar plugin in your HTML file.
2. Add the CSS for the custom scrollbar to your CSS file.
3. In your JavaScript file, select the element(s) you want to apply the custom scrollbar to, and call the plugin function on them.
4. Use the options and methods provided by the plugin to customize the scrollbar as desired.
5. Make sure to include the necessary CSS and image files that come with the plugin in the same directory of your HTML file.
Getting started
It’s pretty easy to get started with Statusfy.
Create a new index.html file with this HTML code..
<div id="page">
<div class="content">
<p>Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum..</p>
</div>
</div>
Create a style.css file with this CSS code.
html,body{
height:100%;
overflow:hidden;
}
body{
margin:0;
padding:0;
color:#eee;
background:#262626;
font-size:14px;
line-height:20px;
}
p{
margin:0 0 20px 0;
font-family: Arial, Helvetica, sans-serif;
}
.content{
width:100%;
height:100%;
box-sizing:border-box;
padding:20px;
overflow:auto;
}
Now add mCustomScrollbar JS and CSS file with jquery, jquery-ui, mousewheel file
<link href="css/jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.7.2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js"></script>
<script src="js/jquery.mousewheel.min.js"></script>
<script src="js/jquery.mCustomScrollbar.min.js"></script>
Create script.js file with this Jaascript Code
<script>
(function($){
$(window).load(function(){
$(".content").mCustomScrollbar({
scrollButtons:{
enable:true
}
});
});
})(jQuery);
</script>
then,
connect the style.css and script.js file in index.html file
I hope you know how to add css and js file in html. Or follow tutorial video..
0 Comments