Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              %h1 Custom CSS Scrollbar

.demo
	%h2 Default
	.scrollbar
		.fake-content
		
.demo
	%h2 Dark
	.scrollbar.scrollbar--dark
		.fake-content
		
.demo
	%h2 Light
	.scrollbar.scrollbar--light
		.fake-content
		
.demo
	%h2 Light Reversed
	.scrollbar.scrollbar--light-reversed
		.fake-content
		
.demo
	%h2 Seafoam
	.scrollbar.scrollbar--seafoam
		.fake-content

.demo
	%h2 Extreme
	.scrollbar.scrollbar--extreme
		.fake-content
	
            
          
!
            
              $blue: #3498db
$green: #1abc9c
$red: #c0392b
$stone: #bdc3c7
$slate: darken($stone, 50)
$yellow: #f1c40f

html
	overflow-y: scroll
	padding: 5%
	background: $stone

img
	max-width: 100%
	vertical-align: bottom

h2
	font-size: 1.1rem

// Demo
// ----

.demo
	float: left
	height: 400px
	margin: 0 1em 0 0
	padding: 0 0 3em
	width: 170px

.scrollbar
	background: #fff
	height: 100%
	overflow: auto
	-webkit-overflow-scrolling: touch
	
.fake-content
	height: 200%
	width: 400%
	$line-color: rgba(#000, .1)
	$line-size: 1px
	$space-between: 50px
	background-image: linear-gradient(to right, $line-color $line-size, transparent $line-size), linear-gradient(to bottom, $line-color $line-size, transparent $line-size)
	background-size: $space-between $space-between


// Sass mixin that customizes the browser scrollbar
//
// $thumb-color - moving part of the scrollbar
// $track-color - background of the scrollbar
// $variation - 'lighten' or 'darken'
// $size - horizontal width and vertical height of the scrollbar
=scrollbars($thumb-color: #606060, $track-color: #393939, $variation: 'lighten', $size: 10px)
	// Firefox:
	// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Scrollbars
	scrollbar-color: $thumb-color $track-color

	@if $size < 15px
		scrollbar-width: thin

	// Webkit:
	// https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar

	&::-webkit-scrollbar
		height: $size
		width: $size
		background-color: red

	&::-webkit-scrollbar-corner
		background: $track-color

	&::-webkit-scrollbar-thumb
		background: $thumb-color
		border: 1px solid $track-color

		&:hover
			@if $variation == 'lighten'
				background: lighten($thumb-color, 15)
			@if $variation == 'darken'
				background: desaturate(darken($thumb-color, 40), 20)
	
		// &:active
		// 	@if $variation == 'lighten'
		// 		background: lighten($thumb-color, 30)
		// 	@if $variation == 'darken'
		// 		background: desaturate(darken($thumb-color, 50), 20)

	&::-webkit-scrollbar-track
		border: 1px solid $track-color
		background-color: $track-color

//
// Variations

.scrollbar--dark
	+scrollbars
	background: rgba(#1c1c1c, .7)

.scrollbar--light
	+scrollbars(#eaeaea, #d4d4d4, 'darken')

.scrollbar--light-reversed
	+scrollbars(#d4d4d4, #eaeaea, 'darken')
	
.scrollbar--seafoam
	+scrollbars(#def1ee, #bcd7d2, 'darken')
	
.scrollbar--extreme
	+scrollbars(gold, crimson, 'lighten', 40px)

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console