Thu Jul 28 2022
Dropdown Menu with Cool Effect
CSS5887 views
File Name: cool-dropdown-menu.html
<!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">
<title>Cool Dropdown Menu</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@500&display=swap" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
font-family: 'Raleway', sans-serif;
}
body {
background-color: #292929;
}
section {
display: flex;
width: 100%;
height: 100vh;
justify-content: center;
align-items: center;
flex-flow: column;
}
nav {
width: 200px;
}
button {
width: 100%;
font-size: 18px;
padding: 10px 0;
border: none;
border-radius: 3px;
cursor: pointer;
}
ul {
list-style: none;
margin-top: 10px;
}
ul li {
margin: 5px 0;
border-radius: 3px;
opacity: 0;
transition: 0.5s all cubic-bezier(0.175, 0.885, 0.32, 1.275);
transition-delay: calc(0.1s * var(--i));
}
ul li:nth-child(odd) {
background-color: #2e86de;
transform: rotateZ(50deg);
transform-origin: left center;
}
ul li:nth-child(even) {
background-color: #54a0ff;
transform: rotateZ(-50deg);
transform-origin: right center;
}
ul.active li {
opacity: 1;
transform: rotateZ(0deg);
}
ul li a {
color: #fff;
text-decoration: none;
font-size: 18px;
padding: 8px 10px;
display: block;
}
</style>
<script>
function toggleMenu() {
let menu = document.getElementById('menu');
menu.classList.toggle('active');
}
</script>
</head>
<body>
<section>
<nav>
<button onclick="toggleMenu()">Web Dev Items</button>
<ul id="menu">
<li style="--i:1"><a href="">HTML/CSS</a></li>
<li style="--i:2"><a href="">JavaScript</a></li>
<li style="--i:3"><a href="">PHP</a></li>
<li style="--i:4"><a href="">Python</a></li>
<li style="--i:5"><a href="">NodeJs</a></li>
</ul>
</nav>
</section>
</body>
</html>
Result Screenshot(s)
Author:Geekboots