File tree Expand file tree Collapse file tree 3 files changed +125
-0
lines changed Expand file tree Collapse file tree 3 files changed +125
-0
lines changed Original file line number Diff line number Diff line change 1+ const toggle = document . getElementById ( "toggle" ) ;
2+ const nav = document . getElementById ( "nav" ) ;
3+
4+ toggle . addEventListener ( "click" , ( ) => nav . classList . toggle ( "active" ) ) ;
Original file line number Diff line number Diff line change 1+ < html lang ="en ">
2+ < head >
3+ < meta charset ="UTF-8 " />
4+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Animated Navigation</ title >
7+ < link rel ="stylesheet " href ="style.css " />
8+ </ head >
9+ < body >
10+ < nav id ="nav ">
11+ < ul >
12+ < li > < a href =""> Home</ a > </ li >
13+ < li > < a href =""> Works</ a > </ li >
14+ < li > < a href =""> About</ a > </ li >
15+ < li > < a href =""> Contacts</ a > </ li >
16+ </ ul >
17+
18+ < button class ="icon " id ="toggle ">
19+ < div class ="line line1 "> </ div >
20+ < div class ="line line2 "> </ div >
21+ </ button >
22+ </ nav >
23+
24+ < script src ="app.js "> </ script >
25+ </ body >
26+ </ html >
Original file line number Diff line number Diff line change 1+ * {
2+ box-sizing : border-box;
3+ margin : 0 ;
4+ padding : 0 ;
5+ }
6+
7+ body {
8+ font-family : sans-serif;
9+ display : flex;
10+ justify-content : center;
11+ align-items : center;
12+ height : 100vh ;
13+ margin : 0 ;
14+ }
15+
16+ nav {
17+ background : # fff ;
18+ padding : 20px ;
19+ width : 80px ;
20+ display : flex;
21+ justify-content : center;
22+ align-items : center;
23+ border-radius : 3px ;
24+ box-shadow : 0 2px 5px rgba (0 , 0 , 0 , 0.3 );
25+ transition : width 0.6s linear;
26+ }
27+
28+ nav .active {
29+ width : 350px ;
30+ }
31+
32+ ul {
33+ display : flex;
34+ list-style : none;
35+ padding : 0 ;
36+ margin : 0 ;
37+ width : 0 ;
38+ transition : width 0.6s linear;
39+ }
40+
41+ nav .active ul {
42+ width : 100% ;
43+ }
44+
45+ nav ul li {
46+ transform : rotate (0deg );
47+ opacity : 0 ;
48+ transition : transfrom 0.6s linear, opacity 0.6s linear;
49+ }
50+
51+ nav .active ul li {
52+ opacity : 1 ;
53+ transform : rotateY (360deg );
54+ }
55+
56+ nav ul a {
57+ position : relative;
58+ color : # 000 ;
59+ text-decoration : none;
60+ margin : 0 10px ;
61+ }
62+
63+ .icon {
64+ background : # fff ;
65+ border : 0 ;
66+ padding : 0 ;
67+ position : relative;
68+ height : 30px ;
69+ width : 30px ;
70+ outline : none;
71+ cursor : pointer;
72+ }
73+
74+ .icon .line {
75+ background : crimson;
76+ height : 2px ;
77+ width : 20px ;
78+ position : absolute;
79+ top : 10px ;
80+ left : 5px ;
81+ transition : transfrom 0.6s linear;
82+ }
83+
84+ .icon .line2 {
85+ top : auto;
86+ bottom : 10px ;
87+ }
88+
89+ nav .active .icon .line1 {
90+ transform : rotate (-765deg ) translateY (5.5px );
91+ }
92+
93+ nav .active .icon .line2 {
94+ transform : rotate (765deg ) translateY (-5.5px );
95+ }
You can’t perform that action at this time.
0 commit comments