I have a modal with a scrollbar.
- The modal has a border-radius of 12px
- The scrollbar has 12px radius too
Problem, the radius does not match.
I would like the part of the scroll bar that is outside of the modal to be hidden.
Here is a playground
Here is the test code :
<div class="h-screen w-screen bg-gray-300">
<div class="fixed left-1/2 top-1/2 h-fit max-h-[70px] w-[200px] -translate-x-1/2 -translate-y-1/2 overflow-y-scroll overflow-hidden rounded-xl bg-white p-3 text-center">
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
</div>
</div>
2
Answers
I think this is a pretty fairly common thing, as I had it like 4 years ago. Surprised its not been fixed yet.
border-radius
andoverflow: hidden
. Similar tricks to adding border on images, or other elements that "block it"overflow: hidden
on the outer container.Here’s how you can modify your code:
HTML:
CSS (Tailwind CSS plus additional scrollbar styling):
Wrap the content that needs to be scrolled in a
div
remove the classesmax-h-[70px] w-[200px] overflow-y-scroll
from parent and place in the newdiv
class.