Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display a checkbox as a slider.
<!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>
@adactio
Copy link
Author

adactio commented Oct 1, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment