I can't figure out how to make the menu item always be centered. In my situation, the container with the text "Name Surname" is not wide enough for its content, causing the menu to be positioned to the right. I have it set to flex: 1 0 auto
which allows it to expand. I have provided a simplified version of my code.
.container {
margin: 0 auto;
width: 100%;
max-width: 950px;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav {
display: flex;
flex: 1 0 auto;
align-items: center;
justify-content: center;
}
.list {
list-style: none;
display: flex;
gap: 20px;
padding: 0;
margin: 0;
}
<div class="container">
<a class="logo" href="/">
<h1>Name Surname</h1>
</a>
<nav class="nav">
<ul class="list">
<li class="item">
<a class="link" href="#about">About me</a>
</li>
<li class="item">
<a class="link" href="#skills">Skills</a>
</li>
<li class="item">
<a class="link" href="#education">Education</a>
</li>
<li class="item">
<a class="link" href="#projects">Projects</a>
</li>
<li class="item">
<a class="link" href="#cv">CV</a>
</li>
<li class="item">
<a class="link" href="#somelink">Some Link</a>
</li>
</ul>
</nav>
<div class="settings">
<button>TM
</button>
<button>LS
</button>
</div>
</div>