Created
October 1, 2014 18:26
-
-
Save adactio/ade708ef8d45350790e8 to your computer and use it in GitHub Desktop.
Display a checkbox as a slider.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Checkbox</title> | |
<style> | |
body { | |
background-color: #fff; | |
color: #000; | |
font-family: sans-serif; | |
} | |
.toggle { | |
background-color: #ccc; | |
display: inline-block; | |
border-radius: 1.2em; | |
padding: 0.2em; | |
} | |
.toggle input { | |
display: none; | |
} | |
.toggle label { | |
transition: margin 0.1s; | |
cursor: pointer; | |
background-color: #999; | |
color: #fff; | |
display: inline-block; | |
padding: 0.25em 1em; | |
border-radius: 1em; | |
margin: 0 1.75em 0 0; | |
} | |
.toggle input:checked + label { | |
background-color: #693; | |
color: #fff; | |
margin: 0 0 0 1.75em; | |
} | |
</style> | |
</head> | |
<body> | |
<span class="toggle"> | |
<input type="checkbox" id="setting" /> | |
<label for="setting">enable</label> | |
</span><!-- /.toggle --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsbin.com/rugonu/edit