<!DOCTYPE html>
<html>
<body>
<nav class="navbar">
<div class="title">My Site</div>
<ul class="menu">
<li class="menu-item"><a href="#">Item-1</a></li>
<li class="menu-item"><a href="#">Item-2</a></li>
<li class="menu-item"><a href="#">Item-3</a></li>
</ul>
</nav>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.navbar {
display: flex;
justify-content: space-between;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
.title {
font-size: 30px;
font-weight: 700;
padding: 20px; // height of the navbar; match with padding of 'a'
}
.menu {
display: flex;
align-items: center;
margin: 0 10px;
gap: 10px;
.menu-item {
list-style: none;
font-size: 22px;
a {
text-decoration: none;
color: black;
padding: 20px; // vertical positioning of border-bottom line
opacity: 0.7;
border-bottom: 5px solid transparent;
}
&:hover {
a {
opacity: 1;
border-bottom: 5px solid orange;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
}
} //menu-item
} //menu
} //navbar
View Compiled
// CSS Only //
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.