【发布时间】:2018-05-02 21:54:02
【问题描述】:
我有这个导航栏:
<div id="nav">
<a href="#">Portfolio</a>
<a href="#"><img src="assets/zslogoblack.png"></a>
<a href="#">Contact</a>
</div>
样式如下:
#nav {
position: fixed;
width: 100%;
}
#nav a {
text-align: center;
display: inline-block;
width: 33%;
}
#nav a:first-of-type,#nav a:last-of-type {
line-height: 60px;
}
#nav img {
height: 60px;
}
这是输出 我需要在 60px 高的固定导航栏中垂直对齐所有内容,但由于某种原因,这没有发生。我以为问题是由
引起的line-height:60px;
被应用于包含图像的锚点,因此
#nav a:first-of-type,#nav a:last-of-type {
line-height: 60px;
}
但这并没有解决问题。任何帮助将不胜感激。
【问题讨论】:
标签: html css image navbar vertical-alignment