When you use baseline
, it is the img
's bottom that will line up with the bottom of the text, as you can see here, where I added a border to the items.
a img{
height: 40px;
border: 1px solid blue;
}
.links{
display: flex;
align-items: baseline;
}
.links a + a {
border: 1px solid blue;
}
<div class="links">
<a class="img-link"> <img src="https://staticaltmetric.s3.amazonaws.com/uploads/2015/10/dark-logo-for-site.png"></a>
<a>Link 1</a>
<a>Link 2</a>
<a>Link 3</a>
</div>
For the img
to align with the text/link elements bottom, you need flex-end
.
a img{
height: 40px;
border: 1px solid red;
}
.links{
display: flex;
align-items: flex-end;
}
.links a {
border: 1px solid blue;
}
<div class="links">
<a class="img-link"> <img src="https://staticaltmetric.s3.amazonaws.com/uploads/2015/10/dark-logo-for-site.png"></a>
<a>Link 1</a>
<a>Link 2</a>
<a>Link 3</a>
</div>
But as you can see in the 2nd sample, there is still a gap below the img
.
This gap all inline element has, and to get rid of that, change the img
's display type to block
.
a img{
display: block;
height: 40px;
border: 1px solid red;
}
.links{
display: flex;
align-items: flex-end;
}
.links a + a {
border: 1px solid blue;
}
<div class="links">
<a class="img-link"> <img src="https://staticaltmetric.s3.amazonaws.com/uploads/2015/10/dark-logo-for-site.png"></a>
<a>Link 1</a>
<a>Link 2</a>
<a>Link 3</a>
</div>