Skip to content

Instantly share code, notes, and snippets.

@ZeeAgency
Created January 2, 2012 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ZeeAgency/1550466 to your computer and use it in GitHub Desktop.
Save ZeeAgency/1550466 to your computer and use it in GitHub Desktop.
The -Webkit-scrollbar challenge
/**
* The -Webkit-scrollbar challenge
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Make the first div’s scrollbar like the second’s
* without changing the styling of the div (i.e. you
* can only change the ::-webkit-scrollbar-* rules
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* It doesn't matter if the second div doesn't look the same
* after your changes, it's only there to show you how the
* end result should look.
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Basically the goal is to see if we can apply some kind
* of margin to the scrollbars to offset them from the edge
*/
div {
width: 350px;
height: 250px;
overflow: auto;
outline: 1px solid;
margin:10px;
box-sizing: border-box;
}
div:first-child {
padding: 10px;
}
div + div {
border: 10px solid transparent;
}
::-webkit-scrollbar {
width: 10px;
height: 10px;
position: relative;
margin:5px;
}
::-webkit-scrollbar-track,
::-webkit-scrollbar-thumb {
border-radius: 10px;
}
::-webkit-scrollbar-track {
box-shadow: 1px 1px 5px rgba(0,0,0,.2) inset;
}
::-webkit-scrollbar-thumb {
background: silver;
}
::-webkit-scrollbar-corner {
background: transparent;
}
/**
* The main trick is to play with transparent borders
*/
div:first-child::-webkit-scrollbar {
width: 30px;
height: 30px;
}
div:first-child::-webkit-scrollbar-track,
div:first-child::-webkit-scrollbar-thumb {
border: 10px solid transparent;
border-radius: 30px;
}
div:first-child::-webkit-scrollbar-thumb {
background: none;
box-shadow: silver 0 0 0 5px inset;
}
<div>
Patch, metafile recursive bridgeware development pc integer backbone overflow, coordinated. High includes supporting supporting in patch n-tier integral analog high. Digital sampling high element interface bridgeware ethernet reducer supporting. Backbone feedback read-only digital technician infrared prototype bridgeware ethernet network. Controller boolean reflective pc logistically, normalizing, processor resistor potentiometer encapsulated bus disk.
Patch bypass bypass boolean pc reducer transistorized kilohertz potentiometer kilohertz, infrared. Developer video remote, prototype audio prototype. Broadband resistor hyperlinked femtosecond encapsulated internet femtosecond, supporting ethernet echo frequency.
Transponder arrray services developer, scan debugged. Bridgeware recursive metafile cache audio, feedback analog, bus reducer distributed. Integer developer read-only, bridgeware fragmentation, services fragmentation bridgeware n-tier partitioned processor. N-tier data resistor harmonic, messaging phaselock, adaptive arrray inversion.
</div>
<div>
Patch, metafile recursive bridgeware development pc integer backbone overflow, coordinated. High includes supporting supporting in patch n-tier integral analog high. Digital sampling high element interface bridgeware ethernet reducer supporting. Backbone feedback read-only digital technician infrared prototype bridgeware ethernet network. Controller boolean reflective pc logistically, normalizing, processor resistor potentiometer encapsulated bus disk.
Patch bypass bypass boolean pc reducer transistorized kilohertz potentiometer kilohertz, infrared. Developer video remote, prototype audio prototype. Broadband resistor hyperlinked femtosecond encapsulated internet femtosecond, supporting ethernet echo frequency.
Transponder arrray services developer, scan debugged. Bridgeware recursive metafile cache audio, feedback analog, bus reducer distributed. Integer developer read-only, bridgeware fragmentation, services fragmentation bridgeware n-tier partitioned processor. N-tier data resistor harmonic, messaging phaselock, adaptive arrray inversion.
</div>
{"view":"split","seethrough":"1","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment