-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const toggle = document.getElementById("toggle"); | ||
const nav = document.getElementById("nav"); | ||
|
||
toggle.addEventListener("click", () => nav.classList.toggle("active")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="./style.css" /> | ||
<title>Animated | Navigation</title> | ||
</head> | ||
<body> | ||
<nav class="active" id="nav"> | ||
<ul> | ||
<li> | ||
<a href="#">Home</a> | ||
</li> | ||
<li> | ||
<a href="#">Works</a> | ||
</li> | ||
<li> | ||
<a href="#">About</a> | ||
</li> | ||
<li> | ||
<a href="#">Contact</a> | ||
</li> | ||
</ul> | ||
|
||
<button class="icon" id="toggle"> | ||
<div class="line line1"></div> | ||
<div class="line line2"></div> | ||
</button> | ||
</nav> | ||
|
||
<script src="./app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
@import url("https://fonts.googleapis.com/css2?family=Muli&display=swap"); | ||
*::after, | ||
*::before { | ||
box-sizing: border-box; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
background-color: #eafbff; | ||
background-image: linear-gradient( | ||
to bottom, | ||
#eafbff 0%, | ||
#eafbff 50%, | ||
#5290f9 50%, | ||
#5290f9 100% | ||
); | ||
font-family: "Muli", sans-serif; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
nav { | ||
background-color: #fff; | ||
padding: 20px; | ||
width: 35px; | ||
height: 20px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 3px; | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); | ||
transition: width 0.6s linear; | ||
} | ||
|
||
nav.active { | ||
width: 350px; | ||
height: 20px; | ||
} | ||
|
||
nav ul { | ||
display: flex; | ||
list-style-type: none; | ||
padding: 0; | ||
margin: 0; | ||
width: 0; | ||
transition: width 0.6s linear; | ||
} | ||
|
||
nav.active ul { | ||
width: 100%; | ||
} | ||
|
||
nav ul li { | ||
transform: rotateY(0deg); | ||
opacity: 0; | ||
transition: transform 0.6s linear, opacity 0.6s linear; | ||
} | ||
|
||
nav.active ul li { | ||
opacity: 1; | ||
transform: rotateY(360deg); | ||
} | ||
|
||
nav ul a { | ||
position: relative; | ||
color: #000; | ||
text-decoration: none; | ||
margin: 0 10px; | ||
text-transform: uppercase; | ||
} | ||
|
||
.icon { | ||
background-color: #fff; | ||
border: 0; | ||
cursor: pointer; | ||
padding: 0; | ||
position: relative; | ||
height: 30px; | ||
width: 30px; | ||
} | ||
|
||
.icon:focus { | ||
outline: 0; | ||
} | ||
|
||
.icon .line { | ||
background-color: #5290f9; | ||
height: 2px; | ||
width: 20px; | ||
position: absolute; | ||
top: 10px; | ||
left: 5px; | ||
transition: transform 0.6s linear; | ||
} | ||
|
||
.icon .line2 { | ||
top: auto; | ||
bottom: 10px; | ||
} | ||
|
||
nav.active .icon .line1 { | ||
transform: rotate(-765deg) translateY(5.5px); | ||
} | ||
|
||
nav.active .icon .line2 { | ||
transform: rotate(765deg) translateY(-5.5px); | ||
} |