Skip to content

Instantly share code, notes, and snippets.

@Raminsiach
Created December 18, 2015 10:45
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Raminsiach/e66de1d8196cfab58d3c to your computer and use it in GitHub Desktop.
Save Raminsiach/e66de1d8196cfab58d3c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Toggle Switch</title>
<style>
.switch {
position: relative;
}
.switch label {
width: 55px;
height: 23px;
position: absolute;
background-color: #999;
top: 0;
left: 0;
border-radius: 50px;
}
.switch input[type="checkbox"] {
visibility: hidden;
}
.switch label:after {
content: '';
width: 21px;
height: 21px;
border-radius: 50px;
position: absolute;
top: 1px;
left: 1px;
transition: all 0.1s;
background-color: white;
}
.switch input[type="checkbox"]:checked + label:after {
left: 33px;
}
.switch input[type="checkbox"]:checked + label {
background-color: green;
}
</style>
</head>
<body>
<div class="switch">
<input type="checkbox" id="checkbox1">
<label for="checkbox1"></label>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment