2.2K 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: 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.4em; 24 width: 1.4em; 25 border: 2px solid #2196F3; 26 border-radius: 1rem 0rem 1rem; 27 transform: rotate(45deg); 28 transition: all .5s ease-in-out; 29} 30 31/* When the checkbox is checked, add a blue background */ 32.container input:checked ~ .checkmark { 33 box-shadow: 0px 0px 40px 5px #2196F3; 34 border-radius: 1rem 0rem 1rem; 35 background-color: #2195f31f; 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.35em; 53 top: 0.20em; 54 width: 0.25em; 55 height: 0.5em; 56 border: solid #2196F3; 57 border-width: 0 0.15em 0.15em 0; 58 transform: rotate(-5deg); 59 animation: upAnimate 0.5s cubic-bezier(0.165, 0.84, 0.44, 1); 60} 61 62@keyframes upAnimate { 63 from { 64 transform: translate(-20px, -20px) rotate(-5deg); 65 opacity: 0; 66 } 67 68 to { 69 transform: translate(0, 0) rotate(-5deg); 70 opacity: 1; 71 } 72}
ercnersoy
Ercan Ersoy
MIT License