|
| 1 | +/* |
| 2 | + Credits: Malik Dellidj |
| 3 | + http://codepen.io/kowlor/pen/ByavWB |
| 4 | +*/ |
| 5 | + |
| 6 | +input.sw { |
| 7 | + opacity: 0; |
| 8 | + position: absolute; |
| 9 | + left: -9999px; |
| 10 | +} |
| 11 | + |
| 12 | +input.sw + label { |
| 13 | + -webkit-user-select: none; |
| 14 | + -moz-user-select: none; |
| 15 | + -ms-user-select: none; |
| 16 | + user-select: none; |
| 17 | + transition: .2s ease; |
| 18 | + display: inline-block; |
| 19 | + height: 30px; |
| 20 | + width: 51px; |
| 21 | + position: relative; |
| 22 | + box-shadow: inset 0 0 0px 2px #e4e4e4; |
| 23 | + border-radius: 60px; |
| 24 | +} |
| 25 | + |
| 26 | +input.sw + label:before { |
| 27 | + content: ""; |
| 28 | + position: absolute; |
| 29 | + display: block; |
| 30 | + height: 30px; |
| 31 | + width: 30px; |
| 32 | + top: 0; |
| 33 | + left: 0; |
| 34 | + border-radius: 15px; |
| 35 | + background: rgba(76, 217, 100, 0); |
| 36 | + transition: 0.2s cubic-bezier(0.24, 0, 0.5, 1); |
| 37 | +} |
| 38 | + |
| 39 | +input.sw + label:after { |
| 40 | + content: ""; |
| 41 | + position: absolute; |
| 42 | + display: block; |
| 43 | + height: 28px; |
| 44 | + width: 28px; |
| 45 | + top: 50%; |
| 46 | + margin-top: -14px; |
| 47 | + left: 1px; |
| 48 | + border-radius: 60px; |
| 49 | + background: #000; |
| 50 | + box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 4px 0px 0 rgba(255, 255, 255, 0.04), 0 4px 9px rgba(255, 255, 255, 0.13), 0 3px 3px rgba(255, 255, 255, 0.05); |
| 51 | + transition: 0.35s cubic-bezier(0.54, 1.6, 0.5, 1); |
| 52 | +} |
| 53 | + |
| 54 | +input.sw:checked + label:after { |
| 55 | + background: #fff; |
| 56 | + box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 4px 0px 0 rgba(0, 0, 0, 0.07), 0 4px 9px rgba(0, 0, 0, 0.15), 0 3px 3px rgba(0, 0, 0, 0.08); |
| 57 | +} |
| 58 | + |
| 59 | +input.sw + label span { |
| 60 | + white-space: nowrap; |
| 61 | + height: 30px; |
| 62 | + line-height: 30px; |
| 63 | + margin-left: 45px; |
| 64 | + padding-left: 16px; |
| 65 | +} |
| 66 | + |
| 67 | +input.sw:checked + label:before { |
| 68 | + width: 51px; |
| 69 | + background: #fff; |
| 70 | + transition: width 0.2s cubic-bezier(0, 0, 0, 0.1) !important; |
| 71 | +} |
| 72 | + |
| 73 | +input.sw:checked + label:after { |
| 74 | + left: 22px; |
| 75 | +} |
| 76 | + |
| 77 | +input.sw:checked + label { |
| 78 | + box-shadow: inset 0 0 0px 25px #e4e4e4; |
| 79 | + transition: box-shadow 2.5s cubic-bezier(0, 1.2, 0.94, 0.95); |
| 80 | +} |
0 commit comments