Logo Luan Morina
Radio buttons as switches with CSS

Radio buttons without styles


Demo HTML

<div class="demo-content">
<div class="demo-switch">
<input type="checkbox" name="checkbox-01" id="demo-checkbox-01">
<label for="demo-checkbox-01"><span>First Item</span></label>
<input type="checkbox" name="checkbox-02" id="demo-checkbox-02">
<label for="demo-checkbox-02"><span>Second Item</span></label>
</div>
</div>

Demo CSS

.demo-switch input[type=checkbox] {
visibility: hidden;
height: 0;
width: 0;
}
.demo-switch label {
position: relative;
display: block;
cursor: pointer;
background-color: #CCCCCC;
border-radius: 100px;
width: 66px;
height: 30px;
}
.demo-switch input:checked + label {
background-color: #63AE6F;
}
.demo-switch input:checked + label::after {
left: calc(100% - 4px);
transform: translateX(-100%);
}
.demo-switch input:checked + label::before {
font: 18px/1 FontAwesome;
position: absolute;
content: '\f00c';
top: 6px;
left: 10px;
color: #FFFFFF;
font-weight: bold;
}
.demo-switch label::after {
content: '';
position: absolute;
top: 4px;
left: 6px;
width: 22px;
height: 22px;
background-color: #FFFFFF;
border-radius: 90px;
transition: 0.3s;
}
.demo-switch span {
display: inline-block;
position: absolute;
width: 160px;
top: 3px;
left: 100px;
}
   HTML checkboxes