I have a requirement of setting custom scroll bar in my application. I have achieved that using -webkit-scrollbar in a class defined by me - 'scroll-bar'. Now I have to apply this class to all my div which takes overflow: auto. Instead, is there any way in Angular or jQuery or scss, that my doms could take the 'scroll-bar' class automatically whenever overflow property is set to it?
I have given a demo here for your better understanding. Please help!
.scrollbar-container
{
margin: 30px;
float:left;
height: 300px;
width: 65px;
background: #F5F5F5;
overflow-y: scroll;
border:1px solid tomato;
}
.force-overflow
{
height: 550px;
}
.scroll-bar::-webkit-scrollbar-track
{
//box-shadow: inset 0 0 6px rgba(0,0,0,0.9);
border:0.5px solid #bababa;
border-radius: 5px;
background-color: #F1F2F7;
}
.scroll-bar::-webkit-scrollbar
{
width: 8px;
height:8px;
background-color: #F5F5F5;
}
.scroll-bar::-webkit-scrollbar-thumb
{
border-radius: 5px;
background-color: green;
}
<!DOCTYPE html>
<html ng-app="myApp" >
<head>
<script src="https://code.angularjs.org/1.4.9/angular.js"></script>
</head>
<body>
<div class="scrollbar-container scroll-bar" >
<div class="force-overflow"></div>
</div>
<div class="scrollbar-container scroll-bar" >
<div class="force-overflow"></div>
</div>
<div class="scrollbar-container scroll-bar" >
<div class="force-overflow"></div>
</div>
</body>
</html>