pure css toggle checkboxes
by Dru Dro
HTML
<form>
<input type="checkbox" id="tick" class="tick"></input>
<label for="tick"><span></span>Some option</label>
<input type="checkbox" id="tick1" class="tick"></input>
<label for="tick1"><span></span>Some option</label>
<input type="checkbox" id="tick2" class="tick"></input>
<label for="tick2"><span></span>Some option</label>
<input type="checkbox" id="tick3" class="tick"></input>
<label for="tick3"><span></span>Some option</label>
<input type="checkbox" id="tick4" class="tick"></input>
<label for="tick4"><span></span>Some option</label>
</form>
CSS
* {
margin:0;
padding: 0;
font: 16pt Arial, sans-serif;
}
form {
display: block;
width: calc(100% - 20px);
margin: 0 auto;
box-sizing: padding-box;
background: rgba(0,0,0,.1);
border-radius: 40px;
}
body {
background: #454545;
}
.tick {
display: none;
}
.tick + label span {
display: inline-block;
width: 49px;
height: 48px;
border-radius: 25px;
box-sizing: border-box;
background: rgba(102, 153, 102, .75);
vertical-align: middle;
transition: all .2s ease-in-out;
z-index: 2;
position: relative;
left: -53px;
top: -3px;
color: white;
margin-right: -35px;
animation: mymove2 .2s;
}
.tick + label span:before {
content:"☐";
display: inline-block;
width: 48px;
height: 48px;
border-radius: 24px;
box-sizing: border-box;
vertical-align: middle;
text-align: center;
line-height: 48px;
position: relative;
color: white;
font-size: 1.5em;
}
.tick + label {
line-height: 50px;
padding: 10px;
display: block;
border-radius: 40px 0 0 40px;
border-bottom: 1px dashed #555;
border-left: 1px dashed #555;
transition: all .2s ease-in-out;
z-index: 0;
overflow: hidden;
height: 50px;
color: white;
}
.tick + label:before {
position: relative;
z-index: 1;
content:"";
display: inline-block;
width: 56px;
height: 56px;
border-radius: 28px;
top: -3px;
left: -2px;
box-sizing: border-box;
vertical-align: middle;
}
.tick:checked + label {
color: #454545;
background: rgba(255, 255, 102, .75);
}
.tick:checked + label span {
background: rgba(255, 255, 102, .75);
animation: mymove .2s;
animation-iteration-count: 1;
}
@keyframes mymove {
0% {transform: scale(1)}
50% {transform: scale(1.3)}
100%{transform:scale(1)}
}
@keyframes mymove2 {
0% {transform: scale(1)}
50% {transform: scale(1.3)}
...