codepens/toggle-checkbox-without-label/dist/style.css

48 lines
912 B
CSS

body {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
input[type="checkbox"] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-webkit-tap-highlight-color: transparent;
cursor: pointer;
}
input[type="checkbox"]:focus {
outline: 0;
}
.toggle {
height: 28px;
width: 46px;
border-radius: 16px;
display: inline-block;
position: relative;
margin: 0;
border: 0;
background: #c7c7cc;
transition: all 0.2s ease;
box-shadow: 0 6px 16px -3px rgba(44, 44, 44, 0.1);
}
.toggle:after {
content: "";
position: absolute;
top: 2px;
left: 2px;
width: 24px;
height: 24px;
border-radius: 50%;
background: white;
box-shadow: 0 1px 2px rgba(44, 44, 44, 0.2);
transition: all 0.2s cubic-bezier(0.5, 0.1, 0.75, 1.35);
}
.toggle:checked {
background: #34c759;
}
.toggle:checked:after {
transform: translatex(18px);
}