#e8e8e8
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: 20px; 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-color: #ccc; 26 transition: all 0.3s; 27 border-radius: 5px; 28} 29 30/* When the checkbox is checked, add a blue background */ 31.container input:checked ~ .checkmark { 32 background-color: #47da99; 33 animation: pop 0.5s; 34 animation-direction: alternate; 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} 48 49/* Style the checkmark/indicator */ 50.container .checkmark:after { 51 left: 0.45em; 52 top: 0.25em; 53 width: 0.25em; 54 height: 0.5em; 55 border: solid white; 56 border-width: 0 0.15em 0.15em 0; 57 transform: rotate(45deg); 58} 59 60@keyframes pop { 61 0% { 62 transform: scale(1); 63 } 64 65 50% { 66 transform: scale(0.9); 67 } 68 69 100% { 70 transform: scale(1); 71 } 72}
Comments
MIT License