如何将徽标和旁边的文字链接对齐在同一高度?这是用display: inline-block;
完成的吗?
a {
text-decoration: none;
color: blue;
}

<nav>
<a href="google.be"><img alt="logo" src="https://vignette.wikia.nocookie.net/simpsons/images/5/51/Wikimedia_logo.png/revision/latest/scale-to-width-down/50?cb=20100313090805"> wikipedia</a>
</nav>
&#13;
答案 0 :(得分:2)
您可以使用Flexbox
并设置align-items: center
。
a {
text-decoration: none;
color: blue;
display: flex;
align-items: center;
}
<a href="google.be"><img alt="logo" src="https://vignette.wikia.nocookie.net/simpsons/images/5/51/Wikimedia_logo.png/revision/latest/scale-to-width-down/50?cb=20100313090805"> wikipedia</a>
答案 1 :(得分:2)
您可以使用flexbox,如另一个答案中所述。您还可以使用vertical-align
属性
a {
text-decoration: none;
color: blue;
}
img {
vertical-align: middle;
}
&#13;
<nav>
<a href="google.be"><img alt="logo" src="https://vignette.wikia.nocookie.net/simpsons/images/5/51/Wikimedia_logo.png/revision/latest/scale-to-width-down/50?cb=20100313090805"> wikipedia</a>
</nav>
&#13;
答案 2 :(得分:0)
只需在图片上添加vertical-align:middle;
img{
vertical-align:middle;
margin-right:5px;
}
<a href="google.be"><img alt="logo" src="https://vignette.wikia.nocookie.net/simpsons/images/5/51/Wikimedia_logo.png/revision/latest/scale-to-width-down/50?cb=20100313090805"> wikipedia</a>
答案 3 :(得分:-1)
a {
text-decoration: none;
color: blue;
}
img{
position:absolute;
}
span{
position:relative;
top:16px;
left:50px;
}
<!-- language: lang-html -->
<nav>
<a href="google.be"><img alt="logo" src="https://vignette.wikia.nocookie.net/simpsons/images/5/51/Wikimedia_logo.png/revision/latest/scale-to-width-down/50?cb=20100313090805"> <span>wikipedia</span></a>
</nav>
<!-- end snippet -->