When using a custom style for a scrollbar in CSS via the ::-webkit-scrollbar selector, then depending on the display property of the target element one either gets a single-button or a double-button.
See the example below, which shows different behavior for elements with display: flex and display: block.
body
{
background: #111;
color: white;
}
.wrapper
{
height: 150px;
overflow-y: scroll;
background: #333;
display: flex;
padding: 10px;
}
.wrapper > div
{
height: 300px;
}
.custom-scrollbar::-webkit-scrollbar
{
width: 16px;
height: 16px;
}
.custom-scrollbar::-webkit-scrollbar-track-piece
{
background-color: #444;
}
.custom-scrollbar::-webkit-scrollbar-thumb
{
background: #555;
}
.custom-scrollbar::-webkit-scrollbar-button
{
background: #666;
}
.custom-scrollbar::-webkit-scrollbar-button:vertical:decrement,
.custom-scrollbar::-webkit-scrollbar-button:vertical:increment,
.custom-scrollbar::-webkit-scrollbar-button:horizontal:decrement,
.custom-scrollbar::-webkit-scrollbar-button:horizontal:increment
{
border: 1px solid #000;
}
.custom-scrollbar::-webkit-scrollbar-button:single-button:vertical:decrement,
.custom-scrollbar::-webkit-scrollbar-button:single-button:vertical:increment,
.custom-scrollbar::-webkit-scrollbar-button:single-button:horizontal:decrement,
.custom-scrollbar::-webkit-scrollbar-button:single-button:horizontal:increment
{
background: #AAA
}
Device: Win10
<br />
Browser: Chrome
<br />
Goal: Custom styled scrollbar without the "double button", regardless of the display property.
<br />
<strong>Question</strong>: How to disable the "double button" completely?
<br />
<br />
<div style="display: flex">
<div style="width: 30%">
<div class="custom-scrollbar wrapper">
<div>
display: flex
<br />
scrollbar: custom
<br />
double-button: visible (= BAD)
</div>
</div>
</div>
<div style="width: 5%">
</div>
<div style="width: 30%">
<div class="custom-scrollbar wrapper" style="display: block">
<div>
display: block
<br />
scrollbar: custom
<br />
double-button: not visible (= GOOD)
</div>
</div>
</div>
</div>
<br />
<br />
<div style="display: flex">
<div style="width: 30%">
<div class="wrapper">
<div>
display: flex
<br />
scrollbar: default
<br />
double-button: not visible (= GOOD)
</div>
</div>
</div>
<div style="width: 5%">
</div>
<div style="width: 30%">
<div class="wrapper" style="display: block">
<div>
display: block
<br />
scrollbar: default
<br />
double-button: not visible (= GOOD)
</div>
</div>
</div>
</div>
CodePen link: https://codepen.io/Acmion/pen/VweKxZa
How do I disable the double-button completely?