-
-
Save matthiasg/3550180 to your computer and use it in GitHub Desktop.
The bi-directional animation is done by using ~ sibling selectors. ps. WebKit only -> uses appearance:none;
Cross-Browser version by @ryanseddon: http://jsfiddle.net/ryanseddon/FeJT2/
This file contains hidden or 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
<input type="radio" name="name" checked /> | |
<input type="radio" name="name" /> | |
<input type="radio" name="name" /> | |
<input type="radio" name="name" /> | |
<input type="radio" name="name" /> |
This file contains hidden or 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
// Radio Inputs with bi-directional animation | |
// by simurai | |
// ps. WebKit only -> uses appearance:none; | |
// Cross-Browser version by @ryanseddon: http://jsfiddle.net/ryanseddon/FeJT2/ |
This file contains hidden or 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
body { | |
padding: 50px; | |
background-color: hsl(0,0%,20%); | |
} | |
input { | |
-webkit-appearance: none; /* remove default */ | |
display: block; | |
margin: 10px; | |
width: 24px; | |
height: 24px; | |
border-radius: 12px; | |
cursor: pointer; | |
vertical-align: middle; | |
box-shadow: hsla(0,0%,100%,.15) 0 1px 1px, inset hsla(0,0%,0%,.5) 0 0 0 1px; | |
background-color: hsla(0,0%,0%,.2); | |
background-image: -webkit-radial-gradient( hsla(200,100%,90%,1) 0%, hsla(200,100%,70%,1) 15%, hsla(200,100%,60%,.3) 28%, hsla(200,100%,30%,0) 70% ); | |
background-repeat: no-repeat; | |
-webkit-transition: background-position .15s cubic-bezier(.8, 0, 1, 1), | |
-webkit-transform .25s cubic-bezier(.8, 0, 1, 1); | |
} | |
input:checked { | |
-webkit-transition: background-position .2s .15s cubic-bezier(0, 0, .2, 1), | |
-webkit-transform .25s cubic-bezier(0, 0, .2, 1); | |
} | |
input:active { | |
-webkit-transform: scale(1.5); | |
-webkit-transition: -webkit-transform .1s cubic-bezier(0, 0, .2, 1); | |
} | |
/* The up/down direction logic */ | |
input, | |
input:active { | |
background-position: 0 24px; | |
} | |
input:checked { | |
background-position: 0 0; | |
} | |
input:checked ~ input, | |
input:checked ~ input:active { | |
background-position: 0 -24px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment