1<style>
2.switch {
3 position: relative;
4 display: inline-block;
5 width: 60px;
6 height: 34px;
7}
8
9.switch input {
10 opacity: 0;
11 width: 0;
12 height: 0;
13}
14
15.slider {
16 position: absolute;
17 cursor: pointer;
18 top: 0;
19 left: 0;
20 right: 0;
21 bottom: 0;
22 background-color: #ccc;
23 -webkit-transition: .4s;
24 transition: .4s;
25}
26
27.slider:before {
28 position: absolute;
29 content: "";
30 height: 26px;
31 width: 26px;
32 left: 4px;
33 bottom: 4px;
34 background-color: white;
35 -webkit-transition: .4s;
36 transition: .4s;
37}
38
39input:checked + .slider {
40 background-color: #2196F3;
41}
42
43input:focus + .slider {
44 box-shadow: 0 0 1px #2196F3;
45}
46
47input:checked + .slider:before {
48 -webkit-transform: translateX(26px);
49 -ms-transform: translateX(26px);
50 transform: translateX(26px);
51}
52
53/* Rounded sliders */
54.slider.round {
55 border-radius: 34px;
56}
57
58.slider.round:before {
59 border-radius: 50%;
60}
61</style>
62</head>
63<body>
64
65<h2>Toggle Switch</h2>
66
67<label class="switch">
68 <input type="checkbox">
69 <span class="slider"></span>
70</label>
71
72<label class="switch">
73 <input type="checkbox" checked>
74 <span class="slider"></span>
75</label><br><br>
76
77<label class="switch">
78 <input type="checkbox">
79 <span class="slider round"></span>
80</label>
81
82<label class="switch">
83 <input type="checkbox" checked>
84 <span class="slider round"></span>
85</label>
86