#212121
1/* Toggle Switch */ 2.toggle-switch { 3 position: relative; 4 display: inline-block; 5 width: 5em; 6 height: 2.5em; 7 font-size: 1em; 8 border-radius: 3em; 9 overflow: hidden; 10 box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; 11} 12 13.toggle-switch input[type="checkbox"] { 14 display: none; 15} 16 17.toggle-switch label { 18 display: block; 19 width: 100%; 20 height: 100%; 21} 22 23.slider { 24 position: absolute; 25 cursor: pointer; 26 top: 0; 27 left: 0; 28 right: 0; 29 bottom: 0; 30 background-color: #fff; 31 border-radius: 3em; 32 box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; 33 transition: background-color 0.3s ease, box-shadow 0.3s ease; 34} 35 36.slider::before { 37 position: absolute; 38 content: ""; 39 width: 2em; 40 height: 2em; 41 left: 0.25em; 42 bottom: 0.25em; 43 background-color: #38b8a7; 44 border-radius: 50%; 45 box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; 46 transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55), background-color 0.3s ease; 47 transform: perspective(800px) rotateY(0deg) rotateX(0deg); 48} 49 50.slider::after { 51 position: absolute; 52 content: ""; 53 width: 0.8em; 54 height: 0.8em; 55 left: 50%; 56 bottom: 0.5em; 57 background-color: #fff; 58 border-radius: 50%; 59 box-shadow: 0 0.1em 0.2em rgba(0, 0, 0, 0.3); 60 transform: translate(-50%, 50%) scale(0); 61 transition: transform 0.3s ease, opacity 0.3s ease; 62 opacity: 0; 63} 64 65.toggle-switch input[type="checkbox"]:checked + .slider { 66 background-color: #f2f2f2; 67 box-shadow: 0 0.3em 0.3em rgba(244, 68, 68, 0.2); 68} 69 70.toggle-switch input[type="checkbox"]:checked + .slider::before { 71 transform: translateX(2.5em) perspective(800px) rotateY(180deg) rotateX(360deg); 72 background-color: #f44; 73 box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; 74} 75 76.toggle-switch input[type="checkbox"]:checked + .slider::after { 77 transform: translate(-50%, 50%) scale(1); 78} 79 80
496 views
496 views
Comments
MIT License