-
-
Save Ralphkay/258d9af45301d368e0b8 to your computer and use it in GitHub Desktop.
Sass mixin for styling scrollbars in webkit by Hugo Giraudel (http://codepen.io/HugoGiraudel/pen/KFDuB)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Mixin scrollbar | |
*/ | |
@mixin scrollbar($size, $primary, $secondary: lighten($primary, 25%)) { | |
::-webkit-scrollbar { | |
width: $size; | |
height: $size; | |
} | |
::-webkit-scrollbar-thumb { | |
background: $primary; | |
} | |
::-webkit-scrollbar-track { | |
background: $secondary; | |
} | |
// For Internet Explorer | |
body { | |
scrollbar-face-color: $primary; | |
scrollbar-track-color: $secondary; | |
} | |
} | |
/** | |
* Call the damn thing | |
*/ | |
@include scrollbar(.5em, tomato); | |
/** | |
* Force scrollbars | |
*/ | |
body { | |
height: 3000px; | |
width: 3000px; | |
} |
Actually doesn't work until you add & symbol before ::-webkit... rules to reference the selector you are applying the mixin to. After that, works like charm
webpack4 sass-loader on win10
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think probably the body css rules are not entirely needed necessary as they easily apply the styles to any scrollbar in the website. Great mixin!!!