I want to get a scrollbar with a thumb larger than the track. I can change the color, the opacity, everything, but I don\'t know how to change the size of the thumbs and the
You can setup your size using width in ::-webkit-scrollbar
.
I don't think it is possible to set separately the thumb and track size.
http://jsfiddle.net/rvcfmun7/
.test {
overflow: auto;
background gray ;
max-height: 500px;
width: 400px;
}
.test::-webkit-scrollbar{
width: 20px;
}
.test::-webkit-scrollbar-track{
background: rgb(41,41,41);
}
::-webkit-scrollbar-thumb{
width: 15px;
background: rgb(111,111,111);
}
To make the thumb smaller than the track/scrollbar, simply add a border to the thumb having the same color as the track.
http://jsfiddle.net/Swiftaxe/75pmwmfw/
.wrapper {
overflow: auto;
background: white;
max-height: 90px;
width: 400px;
padding: 20px 30px;
}
.wrapper::-webkit-scrollbar{
width: 18px;
border-radius: 20px;
}
.wrapper::-webkit-scrollbar-track{
background: #CCEEF4;
border-radius: 20px;
}
::-webkit-scrollbar-thumb{
width: 24px;
background: #49AEC0;
border: 5px solid #CCEEF4;
border-radius: 15px;
}
<div class="wrapper">
<h1>Scrolling is a Virtue</h1>
<p>Well, it's not the first time. About it! There; keep thy finger on it. This is a cogent vice thou hast here, carpenter; let me feel its grip once. So, so; it does pinch some. Oh, sir, it will break bones—beware, beware! No fear; I like a good grip; I like to feel something in this slippery world that can hold, man.</p>
</div>
If the track needs to be transparent one can use background-clip.
Unable to set the width of webkit-scrollbar-thumb
::-webkit-scrollbar {
width: 16px;
height: 100%;
}
::-webkit-scrollbar-thumb:vertical {
height: 100px;
}
This is a really old post, but I have a working solution that does 'EXACTLY' what was asked for. Also, this will come in handy for anybody else needing this solution.
Fiddle
/* SCROLLBAR */
/* Let's get this party started */
::-webkit-scrollbar {
width: 10px;
}
/* Track */
::-webkit-scrollbar-track {
background: rgb(0,0,0);
border: 4px solid transparent;
background-clip: content-box; /* THIS IS IMPORTANT */
}
/* Handle */
::-webkit-scrollbar-thumb {
background: rgb(25,25,25);
border: 1px solid rgb(0,0,0);
}
It is very important to set background-clip: content-box for this to work. You will be left with a track that is thinner than the scroll-bar-thumb. Cheers!!
Another way to do it is assigning border on either side of the track
border-left: 3px solid white; border-right: 3px solid white;
CSS
.cute_scroll::-webkit-scrollbar
{
width: 10px;
background-color: #f8bbd0 ;
}
.cute_scroll::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 6px #f06292 ;
border-radius: 10px;
background-color: #f8bbd0 ;
// Add Border on Track
border-left: 3px solid white;
border-right: 3px solid white;
}
.cute_scroll::-webkit-scrollbar-thumb
{
border-radius: 20px;
-webkit-box-shadow: inset 0 0 px #ad1457 ;
background-color: #e91e63 ;
}
Result
https://codepen.io/hiteshsahu/pen/eGQOwJ
::-webkit-scrollbar-track {
background: url(../../images/scroll-bg.jpg) repeat-y 50%;}
Background is 1px point.