<!--
Checkbox Trickery with CSS:
http://codersblock.com/blog/checkbox-trickery-with-css/
-->
<div class="container">
<input id="toggle1" type="checkbox" checked>
<label for="toggle1">Toggle me!</label>
<input id="toggle2" type="checkbox">
<label for="toggle2">Hey, me too!</label>
<input id="toggle3" type="checkbox">
<label for="toggle3">Toggle party!</label>
</div>
@import url(https://fonts.googleapis.com/css?family=Noto+Sans);
*, *::before, *::after {
box-sizing: border-box;
}
html {
min-height: 100%;
}
body {
color: #435757;
background: radial-gradient(#fff, #dac4cd);
font: 1.4em/1 'Noto Sans', sans-serif;
}
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
input {
position: absolute;
left: -9999px;
}
label {
display: block;
position: relative;
margin: 20px;
padding: 15px 30px 15px 62px;
border: 3px solid #fff;
border-radius: 100px;
color: #fff;
background-color: #6a8494;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
white-space: nowrap;
cursor: pointer;
user-select: none;
transition: background-color .2s, box-shadow .2s;
}
label::before {
content: '';
display: block;
position: absolute;
top: 10px;
bottom: 10px;
left: 10px;
width: 32px;
border: 3px solid #fff;
border-radius: 100px;
transition: background-color .2s;
}
label:first-of-type {
transform: translateX(-40px);
}
label:last-of-type {
transform: translateX(40px);
}
label:hover, input:focus + label {
box-shadow: 0 0 20px rgba(0, 0, 0, .6);
}
input:checked + label {
background-color: #ab576c;
}
input:checked + label::before {
background-color: #fff;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.