Sat May 28 2022
Navbar with Dropdown Menu
CSS5406 views
File Name: CSS3-Navbar-withing-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>CSS 3 Navbar and Dropdown Menu</title>
<style>
* {
margin: 0;
padding: 0;
font-family: 'Inter', sans-serif;
}
body {
background-color: #383838;
}
nav {
max-width: 900px;
/* margin: 30px 50px 0 50px; */
margin: 30px auto 0 auto;
background: linear-gradient(30deg, #86e3ce, #d0e6a5);
padding: 0 20px;
border-radius: 10px;
box-shadow: 0 5px 5px 0 #181818;
}
nav ul {
list-style: none;
display: flex;
width: 100%;
justify-content: space-between;
}
nav ul li {
width: calc(100% / 5);
border-right: #ddf1b5 solid thin;
position: relative;
}
nav ul li:last-child { border-right: none; }
nav ul li a {
display: block;
text-align: center;
padding: 15px 0;
text-decoration: none;
color: #004d3b;
font-weight: bold;
font-size: 15px;
transition: 0.2s all ease-in-out;
}
nav ul li a svg {
width: 15px;
height: 15px;
display: inline-block;
vertical-align: middle;
margin-left: 5px;
}
nav ul li:hover a {
background-color: #3bcfad;
}
nav ul li > ul {
position: absolute;
flex-flow: column;
background: linear-gradient(30deg, #d0e6a5, #ffdd94);
width: 200px;
top: 100%;
right: 50%;
transform: translateX(50%);
border-radius: 0 0 20px 20px;
z-index: -1;
box-shadow: 0 5px 5px 0 #181818;
overflow: hidden;
visibility: hidden;
opacity: 0;
transition: 0.2s all ease-in-out;
}
nav ul li:hover > ul {
visibility: visible;
opacity: 1;
}
nav ul li > ul li {
width: 100%;
border-right: none;
border-bottom: #ddf1b5 solid thin;
}
nav ul li > ul li:last-child { border-bottom: none; }
nav ul li:hover > ul li a {
padding: 12px 0;
background-color: transparent;
}
nav ul li > ul li:hover a { background-color: #f8c350; }
</style>
</head>
<body>
<nav>
<ul>
<li>
<a href="">Home</a>
</li>
<li>
<a href="">About Us</a>
</li>
<li>
<a href="">
Services
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7" />
</svg>
</a>
<ul>
<li>
<a href="">Web Design</a>
</li>
<li>
<a href="">Web Development</a>
</li>
<li>
<a href="">Graphic Design</a>
</li>
<li>
<a href="">Android Dev</a>
</li>
</ul>
</li>
<li>
<a href="">Portfolio</a>
</li>
<li>
<a href="">Contact Us</a>
</li>
</ul>
</nav>
</body>
</html>
Result Screenshot(s)
Author:Geekboots