Back
Checkbox
1 2<label class="container">3 <input checked="checked" type="checkbox">4 <div class="checkmark"></div>5</label>
1 2/* Hide the default checkbox */ 3.container input { 4 position: absolute; 5 opacity: 0; 6 cursor: pointer; 7 height: 0; 8 width: 0; 9}10 11.container {12 display: block;13 position: relative;14 cursor: pointer;15 font-size: 25px;16 user-select: none;17}18 19/* Create a custom checkbox */20.checkmark {21 position: relative;22 top: 0;23 left: 0;24 height: 1.3em;25 width: 1.3em;26 background: black;27 border-radius: 50px;28 transition: all 0.7s;29 --spread: 20px;30}31 32/* When the checkbox is checked, add a blue background */33.container input:checked ~ .checkmark {34 background: black;35 box-shadow: -10px -10px var(--spread) 0px #5B51D8, 0 -10px var(--spread) 0px #833AB4, 10px -10px var(--spread) 0px #E1306C, 10px 0 var(--spread) 0px #FD1D1D, 10px 10px var(--spread) 0px #F77737, 0 10px var(--spread) 0px #FCAF45, -10px 10px var(--spread) 0px #FFDC80;36}37 38/* Create the checkmark/indicator (hidden when not checked) */39.checkmark:after {40 content: "";41 position: absolute;42 display: none;43}44 45/* Show the checkmark when checked */46.container input:checked ~ .checkmark:after {47 display: block;48}49 50/* Style the checkmark/indicator */51.container .checkmark:after {52 left: 0.45em;53 top: 0.25em;54 width: 0.25em;55 height: 0.5em;56 border: solid #f0f0f0;57 border-width: 0 0.15em 0.15em 0;58 transform: rotate(45deg);59}
MIT License