I am making a navigation and I added top and bottom padding to my li elements because I'm changing their background color to black if they're selected. However, if I add top and bottom padding to my logo (h1 element) it will not be vertically centered in the nav. How can I vertically center my logo?
Here is the codepen link: https://codepen.io/tonyutoko/pen/NWKreyQ
I also posted the code below.
* {
margin: 0;
padding: 0;
}
a { text-decoration: none; }
.clearfix:after {
content: " "; /* Older browser do not support empty content */
visibility: hidden;
display: block;
height: 0;
clear: both;
}
.container {
max-width: 58.75rem;
margin: 0 auto;
}
nav {
background-color: blue;
}
.left-group {
float: left;
}
nav ul li {
display: inline-block;
margin-right: 0.5em;
padding: 0.75em;
}
nav ul li:last-child {
margin-right: 0;
}
nav ul li a, nav h1 a {
color: #fff;
}
.selected {
background-color: #111;
}
.right-group {
float: right;
}
<nav>
<div class="container clearfix">
<div class="left-group">
<ul>
<li class="selected"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div class="right-group">
<h1><a href="#">Logo</a></h1>
</div>
</div>
</nav>