Skip to content

Instantly share code, notes, and snippets.

@huffmanks
Created August 21, 2022 01:56
Show Gist options
  • Save huffmanks/7625bee3575bf5b4a69b0b2daa0e9ba9 to your computer and use it in GitHub Desktop.
Save huffmanks/7625bee3575bf5b4a69b0b2daa0e9ba9 to your computer and use it in GitHub Desktop.
Custom scrollbar CSS
/*
* @title Custom scrollbar
* @note For vertical switch overflow-x and scroll-snap-type to 'y'.
* @html <div class='scrollbar-horizontal'>
* <div class='child'>...</div>
* </div>
*/
.scrollbar-horizontal {
overflow-x: auto;
scroll-behavior: smooth;
scroll-snap-type: x mandatory;
}
.scrollbar-horizontal .child {
scroll-snap-align: center;
}
.scrollbar-horizontal::-webkit-scrollbar {
width: 24px;
height: 24px;
background-color: transparent;
}
.scrollbar-horizontal::-webkit-scrollbar-track {
background-color: transparent;
border-radius: 9999px;
}
.scrollbar-horizontal::-webkit-scrollbar-thumb {
background-color: rebeccapurple;
background-clip: padding-box;
border: solid 8px transparent;
border-radius: 9999px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment