I customize scrollbar by CSS3. And I don't know, how to make scrollbar-thumb smaller (shorter). Width or height don't work. Can anybody help me?
#parent { width: 300px; height: 300px; padding: 20px; overflow: auto; } #child { width: 250px; height: 1000px; margin: 0 auto; border: 2px solid #8c1b21; } #parent::-webkit-scrollbar { width: 15px; background-color: #B79889; border-radius: 5px; box-shadow: inset 0 0 6px rgba(0,0,0,0.3); } #parent::-webkit-scrollbar-thumb { background-color: #8c1b21; border-radius: 5px; }
<div id="parent"> <div id="child"></div> </div>
Height of thumb depends on the height of the div
where you are applying scroll
#parent { width: 300px; height: 300px; padding: 20px; overflow: auto; } #child { width: 250px; height: 4000px; margin: 0 auto; border: 2px solid #8c1b21; } #parent::-webkit-scrollbar { width: 10px; background-color: #B79889; border-radius: 5px; box-shadow: inset 0 0 6px rgba(0,0,0,0.3); } #parent::-webkit-scrollbar-thumb { background-color: #8c1b21; border-radius: 5px; }
<div id="parent"> <div id="child"></div> </div>
This works for me, "::-webkit-scrollbar /width" is the key
::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
background-color: #F5F5F5;
}
::-webkit-scrollbar
{
width: 4px !important;
background-color: #F5F5F5;
}
::-webkit-scrollbar-thumb
{
background-color: $apple-gray;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.