How can I keep the scrollbar thumb height fixed so that it doesn't grow shorter and longer with respect to the contents size. Is this possible?
I have just created a snippet for you people to take a look at to get the idea:
var IncreaseInterval;
var DecreaseInterval;
var ToStop = false;
function increaseHeight() {
var newHeight = $('.force-overflow').height() + 500;
$('.force-overflow').css('height', newHeight+'px');
if (newHeight >= 4500) {
clearInterval(IncreaseInterval);
if (ToStop == false) {
setTimeout(function() { DecreaseInterval = setInterval(decreaseHeight, 1000); }, 3000);
}
}
}
function decreaseHeight() {
var newHeight = $('.force-overflow').height() - 500;
$('.force-overflow').css('height', newHeight+'px');
if (newHeight < 1000) {
clearInterval(DecreaseInterval);
IncreaseInterval = setInterval(increaseHeight, 1000);
ToStop = true;
}
}
IncreaseInterval = setInterval(increaseHeight, 1000);
body {
background-color: #f7f7f7;
}
.scrollbar {
height: 300px;
overflow-y: scroll;
margin:0 auto;
width:400px;
}
.force-overflow {
height: 600px;
padding:right:20px;
}
/*
* STYLE 1
*/
.cute_scroll::-webkit-scrollbar {
width: 20px;
background-color: #f7f7f7;
}
.cute_scroll::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px #dfe0e4;
border-radius: 10px;
background-color: #f8bbd0;
border-left: 9.5px solid #f7f7f7;
border-right: 9.4px solid #f7f7f7;
}
.cute_scroll::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 px #ad1457 ;
background: #f5827d;
background-clip: padding-box;
border: 3px solid rgba(245, 130, 125, 0.4);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="scrollbar cute_scroll">
<div class="force-overflow">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem 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.
</div>
</div>
