File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Document</ title >
7+ </ head >
8+ < body >
9+ < main >
10+ < div class ="toggle " id ="toggle ">
11+ < div class ="toggle-indicator "> </ div >
12+ </ div >
13+ </ main >
14+
15+ < style >
16+ body {
17+ margin : 0 ;
18+ overflow : hidden;
19+ display : flex;
20+ justify-content : center;
21+ align-items : center;
22+ -webkit-tap-highlight-color : transparent;
23+ width : 100vw ;
24+ height : 100vh ;
25+ background-color : # fff ;
26+ }
27+
28+ .toggle {
29+ position : relative;
30+ cursor : pointer;
31+ width : 200px ;
32+ height : 100px ;
33+ border-radius : 100px ;
34+ background-color : rgba (235 , 235 , 235 , 1 );
35+ transition : all 0.5s ease-in-out;
36+ }
37+
38+ .toggle-on {
39+ border-radius : 0px ;
40+ }
41+
42+ .toggle-indicator {
43+ position : absolute;
44+ top : 0% ;
45+ left : 0% ;
46+ width : 100px ;
47+ height : 100px ;
48+ border-radius : 100px ;
49+ background-color : rgba (200 , 200 , 200 , 1 );
50+ transition : all 0.5s ease-in-out;
51+ }
52+
53+ .toggle-on .toggle-indicator {
54+ left : calc (100% - 100px );
55+ border-radius : 0px ;
56+ rotate : 180deg ;
57+ background-color : rgba (0 , 0 , 0 , 1 );
58+ }
59+ </ style >
60+
61+ < script >
62+ const toggle = document . getElementById ( "toggle" ) ;
63+
64+ toggle . addEventListener ( "click" , ( ) => {
65+ toggle . classList . toggle ( "toggle-on" ) ;
66+ } ) ;
67+ </ script >
68+ </ body >
69+ </ html >
You can’t perform that action at this time.
0 commit comments