I have problem with vertically centering the element in the navigation bar on my page. This is my code:
body {
margin:0;
}
header {
background-color: #f2f2f2;
height: 50px;
}
div {
display: flex;
justify-content: space-between;
margin: auto 30px;
}
<header>
<div>
<a href="#"><img class="header-logo" alt="logo"></a>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Contact</a>
</nav>
</div>
</header>
My question is why the div
element is not centered in the header
, since in the CSS code the top and bottom margins of the div
element are set to auto
, and that's what I do to center vertically.