Skip to content

Instantly share code, notes, and snippets.

@madpilot
Created December 6, 2011 06:46
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 madpilot/1437093 to your computer and use it in GitHub Desktop.
Save madpilot/1437093 to your computer and use it in GitHub Desktop.
CSS to create a CSS3 only slider.
input[type=checkbox] {
border: 1px solid #686868;
height: 27px;
width: 79px;
-webkit-appearance: none;
-webkit-border-radius: 13px;
background-image: url(/blog/wp-content/uploads/2011/12/checkbox-background.png);
background-position: -52px 0;
background-repeat: no-repeat;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-duration: 400ms;
-webkit-animation-name: checkbox-switch-off;
}
input:checked[type=checkbox] {
background-position: 0 0;
-webkit-animation-name: checkbox-switch-on;
}
@-webkit-keyframes checkbox-switch-on {
from {
background-position: -52px 0;
}
to {
background-position: 0 0;
}
}
@-webkit-keyframes checkbox-switch-off {
from {
background-position: 0 0;
}
to {
background-position: -52px 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment