Menu #9
Give your rating
3
2 votes
- 12+
- 26+
- 29+
- 12.1+
- 9+
- 26+
- 29+
- 14+
- 9+
- 1.5+
- 37+
Demo
- 2.63 KB
- HTML, CSS
- Menu
- dropdown, horizontal
- MIT License
HTML
<nav role="navigation">
<ul>
<li><a href="#">Home</a></li>
<li>
<a href="#">About</a>
<ul>
<li><a href="">Our team</a></li>
<li><a href="">History</a></li>
</ul>
</li>
<li><a href="#">Clients</a></li>
<li>
<a href="#">Contact Us</a>
<ul>
<li><a href="">Address</a></li>
<li><a href="">Managers</a></li>
</ul>
</li>
</ul>
</nav>
CSS
@import url(https://fonts.googleapis.com/css?family=Lato);
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font-family: "Lato", sans-serif;
}
nav {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #fff;
-webkit-box-shadow: 0 3px 10px -2px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 3px 10px -2px rgba(0, 0, 0, 0.1);
box-shadow: 0 3px 10px -2px rgba(0, 0, 0, 0.1);
border: 1px solid rgba(0, 0, 0, 0.1);
}
nav ul {
list-style: none;
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: flex;
padding: 0;
margin: auto;
max-width: 70%;
}
nav ul li {
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: flex;
margin: auto;
-webkit-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
nav ul li:hover {
background: rgba(0, 0, 0, 0.15);
}
nav ul li:hover > ul {
display: block;
}
nav ul li {
float: left;
-webkit-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
nav ul li a {
display: block;
padding: 30px 20px;
color: #222;
font-size: 0.9em;
letter-spacing: 1px;
text-decoration: none;
text-transform: uppercase;
}
nav ul ul {
display: none;
background: #fff;
position: absolute;
top: 100%;
-webkit-box-shadow: -3px 3px 10px -2px rgba(0, 0, 0, 0.1);
-moz-box-shadow: -3px 3px 10px -2px rgba(0, 0, 0, 0.1);
box-shadow: -3px 3px 10px -2px rgba(0, 0, 0, 0.1);
border: 1px solid rgba(0, 0, 0, 0.1);
}
nav ul ul li {
float: none;
position: relative;
}
nav ul ul li a {
padding: 15px 30px;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
nav ul ul ul {
position: absolute;
left: 100%;
top: 0;
}
The code snippet we’re looking into creates a sleek and user-friendly dropdown menu embedded within a horizontal menu structure, perfect for a website’s navigation bar. At the heart of this setup is the HTML