I have a navigation bar built using flexbox and would like 3 sections. Links on the left, links on the right, and the logo in the center. However, if I try to use flexbox for this, my logo ends up offset if the content of the links on the left are different from those on the right. So how do I center my logo?
This is the HTML:
<nav>
<div class="logo">
<img src="img/logo.svg"/>
</div>
<ul>
<li><a href="/about.html" class="selected">Home</a></li>
<li><a href="/about.html">About</a></li>
<li><a href="/about.html">Work</a></li>
<li><a href="/about.html">Contact</a></li>
</ul>
</nav>
This is the CSS:
nav {
display: flex;
text-align: center;
}
nav > .logo {
flex-grow: 1;
}
nav > .logo > img {
height: 1rem;
}
nav > ul {
display: flex;
margin: 0;
padding: 0;
list-style: none;
}
nav > ul > li {
margin: 0 1rem;
}