Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<!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