I created a navbar in my header and aligned it with another element so that they were centered. However, after adding an image to the header, one of the elements is no longer centered:
#header nav {
display: inline;
}
#header {
background: #5D6D63;
padding: 28px 0 26px;
position: fixed;
top: 0;
left: 0;
z-index: 1000;
width: 100%;
}
#header nav ul {
float: right;
margin: 0px;
margin-right: 100px;
}
li {
list-style-type: none;
float: left;
margin-left: 46px;
}
a[href^="#"] {
color: #fff;
font-size: 20px;
font-weight: bold;
letter-spacing: -1px;
text-decoration: none
}
a[href="#top"] {
margin-left: 100px;
}
<header id="header">
<a href="#top">Name</a>
<a href="https://github.com/">
<img src="assets/imgs/GitHub-Mark-Light-64px.png" alt="GitHub" height="24" width="24">
</a>
<nav id="navbar">
<ul>
<li><a href="#">Link 1</a>
</li>
<li><a href="#">Link 2</a>
</li>
<li><a href="#">Link 3</a>
</li>
</ul>
</nav>
</header>
The issue is the vertical alignment of the Name anchor tag. It should be centered with the the github image and the navbar. If I remove the github image, it works fine and it is aligned. Why is the github image causing the Name anchor tag to be pushed down a few pixels?
Here are pictures to show it misaligned (with image) and aligned (without image)