Mon Jul 18 2022
Creative Dropdown Menu
CSS5855 views
File Name: creative-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>Amazing 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;
}
button {
background-color: #fff;
color: #ed4e6e;
font-size: 18px;
padding: 8px 20px;
border-radius: 5px;
border: none;
cursor: pointer;
}
ul#menu {
list-style: none;
width: 200px;
margin-top: 20px;
}
ul#menu li {
margin: 5px 0;
opacity: 0;
transition: 0.5s all cubic-bezier(0.31,-0.105,0.43,1.4);
}
ul#menu li:nth-child(even) {
transform: translateX(50px);
}
ul#menu li:nth-child(odd) {
transform: translateX(-50px);
}
ul#menu li:nth-child(1) {
transition-delay: 0.1s;
}
ul#menu li:nth-child(2) {
transition-delay: 0.2s;
}
ul#menu li:nth-child(3) {
transition-delay: 0.3s;
}
ul#menu li:nth-child(4) {
transition-delay: 0.4s;
}
ul#menu.active li {
opacity: 1;
transform: translateX(0px);
}
ul#menu li a {
background-color: #ed4e6e;
display: block;
padding: 8px 20px;
font-weight: 500;
color: #fff;
text-decoration: none;
border-radius: 3px;
}
</style>
<script>
function toggleMenu() {
let menu = document.getElementById('menu');
menu.classList.toggle('active');
}
</script>
</head>
<body>
<section>
<button onclick="toggleMenu()">Menu</button>
<ul id="menu">
<li><a href="">Home</a></li>
<li><a href="">About Us</a></li>
<li><a href="">Services</a></li>
<li><a href="">Contact us</a></li>
</ul>
</section>
</body>
</html>
Result Screenshot(s)
Author:Geekboots