I'm trying to make some kind of fluid header or whatever. The problem is that I noticed that when I add position:absolute
to a
elements, it adds 4 pixels to the header:
And if I remove position:absolute
, then it doesn't add 4 additional pixels to the height:
Here's what I came up with so far:
<div class="content-container">
<a href="#" class="header-logo"><img src="https://i.imgur.com/bn2vAjo.png" alt="" title=""></a>
<nav class="main-menu">
<ul>
<li><a href="">Journal</a></li>
<li><a href="">About</a></li>
<li><a href="">About</a></li>
<li><a href="">Contact</a></li>
</ul>
</nav>
</div>
.content-container {
background: #292929;
margin: 0 auto;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.header-logo {
align-self: center;
}
nav.main-menu {
align-self: center;
}
nav.main-menu li {
display:inline-block;
width: 132px;
height: 132px;
font-weight:600;
position: relative;
}
nav.main-menu li a {
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
* {
border: 0 !important;
margin: 0 !important;
padding: 0 !important;
}
https://jsfiddle.net/yafs3yoo/
I am obviously missing something here but I can't figure it out myself. I want this header to be exactly 132 pixels high (with borders), logo to be on the left side (centered vertically) and menu to be on the right side (centered vertically). How to get rid of these additional 4 pixels in the header?