To put it simple, this is what i want (obtained on a Webkit Browser using -webkit-scrollbar) :
And this is what I get on Opera (Firefox doesn't apply the border radius to the scrollbar either, but still applies the border) :
Is there a simple way to make the border not disappear under the scrollbar ?
I dont need the fancy style of -webkit-scrollbar but i would like the page to look clean and symmetric...
CSS Syntaxborder-radius: 1-4 length|% / 1-4 length|%|initial|inherit; Note: The four values for each radius are given in the order top-left, top-right, bottom-right, bottom-left. If bottom-left is omitted it is the same as top-right. If bottom-right is omitted it is the same as top-left.
As of 2020, 96% of internet users are running browsers that support CSS scrollbar styling. However, you will need to write two sets of CSS rules to cover Blink and WebKit and also Firefox browsers. In this tutorial, you will learn how to use CSS to customize scrollbars to support modern browsers.
auto is the default value and will render the standard scrollbars for the user agent. thin will tell the user agent to use thinner scrollbars, when applicable. none will hide the scrollbar completely, without affecting the element's scrollability.
I've been having the same issue. It's not the most elegant of solutions but, simply put a smaller div inside your outer box so the scroll bar doesn't overlap the outer box.
Like this code copied from this pen:
.box { height: 200px; width: 250px; border-radius: 10px; border: 2px solid #666; padding: 6px 0px; background: #ccc; } .box-content { height: 200px; width: 250px; overflow: auto; border-radius: 8px; }
<div class="box"> <div class="box-content"> <ol> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> </ol> </div> </div>
Put the content that needs to be scrolled in a div
with overflow: auto
. Around that content div
put a div
with your rounded corners and overflow: hidden
.
Now you can see the scroll bar but its outer corners are hidden and are not disturbing the rounded corners of the outer div
.
Example:
// Insert placeholder text document.querySelector('.inner').innerHTML = 'Text<br>'.repeat(20);
.outer { width: 150pt; border: 1px solid red; border-radius: 15pt; overflow: hidden; } .inner { height: 200px; overflow-y: auto; }
<div class="outer"> <div class="inner"> <!-- lots of text here --> </div> </div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With