623 views
1/* Hide the default checkbox */ 2.container input { 3 position: absolute; 4 opacity: 0; 5 cursor: pointer; 6 height: 0; 7 width: 0; 8} 9 10.container { 11 display: block; 12 position: relative; 13 cursor: pointer; 14 font-size: 25px; 15 user-select: none; 16} 17 18/* Create a custom checkbox */ 19.checkmark { 20 position: relative; 21 top: 0; 22 left: 0; 23 height: 1.3em; 24 width: 1.3em; 25 background: black; 26 border-radius: 50px; 27 transition: all 0.7s; 28 --spread: 20px; 29} 30 31/* When the checkbox is checked, add a blue background */ 32.container input:checked ~ .checkmark { 33 background: black; 34 box-shadow: -10px -10px var(--spread) 0px #FFD700, 0 -10px var(--spread) 0px #FFD700, 10px -10px var(--spread) 0px #FFD700, 10px 0 var(--spread) 0px #FFD700, 10px 10px var(--spread) 0px #FFD700, 0 10px var(--spread) 0px #FFD700, -10px 10px var(--spread) 0px #FFD700; 35} 36 37/* Create the checkmark/indicator (hidden when not checked) */ 38.checkmark:after { 39 content: ""; 40 position: absolute; 41 display: none; 42} 43 44/* Show the checkmark when checked */ 45.container input:checked ~ .checkmark:after { 46 display: block; 47 animation: checkmark 0.3s cubic-bezier(0.25, 0.1, 0.25, 1) forwards; 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 #FFD700; 57 border-width: 0 0.15em 0.15em 0; 58 transform: rotate(45deg); 59} 60 61/* Add animation for checkmark */ 62@keyframes checkmark { 63 from { 64 transform: rotate(-45deg) scale(0); 65 } 66 67 to { 68 transform: rotate(45deg) scale(1); 69 } 70} 71 72/* Style the label text */ 73.container span { 74 margin-left: 2em; 75 color: black; 76 font-weight: bold; 77} 78
MIT License