File tree 3 files changed +134
-0
lines changed
3 files changed +134
-0
lines changed 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
+ < link rel ="stylesheet " href ="style.css " />
7
+ < title > Animated Navigation</ title >
8
+ </ head >
9
+ < body >
10
+ < nav class ="active " 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 ="# "> Contact</ a > </ li >
16
+ </ ul >
17
+ < button class ="icon " id ="toggle ">
18
+ < div class ="line line1 "> </ div >
19
+ < div class ="line line2 "> </ div >
20
+ </ button >
21
+ </ nav >
22
+ < script src ="script.js "> </ script >
23
+ </ body >
24
+ </ html >
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
+ @import url ("https://fonts.googleapis.com/css2?family=Muli&display=swap" );
2
+
3
+ * {
4
+ box-sizing : border-box;
5
+ }
6
+
7
+ body {
8
+ background-color : # eafbff ;
9
+ background-image : linear-gradient (
10
+ to bottom,
11
+ # eafbff 0% ,
12
+ # eafbff 50% ,
13
+ # 5290f9 50% ,
14
+ # 5290f9 100%
15
+ );
16
+ font-family : "Muli" , sans-serif;
17
+ display : flex;
18
+ align-items : center;
19
+ justify-content : center;
20
+ height : 100vh ;
21
+ margin : 0 ;
22
+ }
23
+
24
+ nav {
25
+ background-color : # fff ;
26
+ padding : 20px ;
27
+ width : 80px ;
28
+ display : flex;
29
+ align-items : center;
30
+ justify-content : center;
31
+ border-radius : 3px ;
32
+ box-shadow : 0 2px 5px rgba (0 , 0 , 0 , 0.3 );
33
+ transition : width 0.6s linear;
34
+ }
35
+
36
+ nav .active {
37
+ width : 350px ;
38
+ }
39
+
40
+ nav ul {
41
+ display : flex;
42
+ list-style-type : none;
43
+ padding : 0 ;
44
+ margin : 0 ;
45
+ width : 0 ;
46
+ transition : width 0.6s linear;
47
+ }
48
+
49
+ nav .active ul {
50
+ width : 100% ;
51
+ }
52
+
53
+ nav ul li {
54
+ transform : rotateY (0deg );
55
+ opacity : 0 ;
56
+ transition : transform 0.6s linear, opacity 0.6s linear;
57
+ }
58
+
59
+ nav .active ul li {
60
+ transform : rotateY (360deg );
61
+ opacity : 1 ;
62
+ }
63
+
64
+ nav ul a {
65
+ position : relative;
66
+ color : # 000 ;
67
+ text-decoration : none;
68
+ margin : 0 10px ;
69
+ }
70
+
71
+ .icon {
72
+ background-color : # fff ;
73
+ border : 0 ;
74
+ cursor : pointer;
75
+ padding : 0 ;
76
+ position : relative;
77
+ height : 30px ;
78
+ width : 30px ;
79
+ }
80
+
81
+ .icon : focus {
82
+ outline : 0 ;
83
+ }
84
+
85
+ .icon .line {
86
+ background-color : # 5290f9 ;
87
+ height : 2px ;
88
+ width : 20px ;
89
+ position : absolute;
90
+ top : 10px ;
91
+ left : 5px ;
92
+ transition : transform 0.6s linear;
93
+ }
94
+
95
+ .icon .line2 {
96
+ top : auto;
97
+ bottom : 10px ;
98
+ }
99
+
100
+ nav .active .icon .line1 {
101
+ transform : rotate (-765deg ) translateY (5.5px );
102
+ }
103
+
104
+ nav .active .icon .line2 {
105
+ transform : rotate (765deg ) translateY (-5.5px );
106
+ }
You can’t perform that action at this time.
0 commit comments