css - 为什么这个导航栏中的矢量和文本不垂直对齐?
问题描述
我正在开发 HTML 中的导航栏。我不明白为什么元素在导航栏中不能很好地排列。
body {
background-color: #ECEFF1; /* Blue Gray 50 */
font-family: 'Roboto', sans-serif;
margin: 0;
}
#header {
background-color: #ba68c8; /* Purple 300 */
color: #ffffff; /* White */
height: 24px;
padding: 8px;
}
.header-link {
font-size: 24px;
text-decoration: none;
}
<div id="header">
<a class="header-logo" href="#">
<img src="http://www.sigmacubes.com/img/logo_h.svg" height="24" />
</a>
<a class="header-link" href="#">
Text
</a>
</div>
尽管 svg 是垂直对齐的,但文本不会保持垂直对齐。为什么会这样?
解决方案
是vertical-align:middle;
您的标题链接类的选项吗?如果进一步匹配您想要的外观,display: table-cell;
可能会添加。vertical-align:middle;
推荐阅读
- ios - 如何在 Apple Connect 中获取 ProductID?(应用内购买)
- c# - 我在我的服务总线队列中调用了一个长时间运行的进程。我希望它持续超过 5 分钟
- c++ - 分离线程中的竞争条件
- python - 从 Python 3.5 升级到 3.7,但 IPython 仍然使用 3.5
- python - Python Script 自己运行了两次
- php - 如何检查相同键对的多维数组,即完全相同的键但值可能不同?
- regex - 使用 Perl 在 Excel 文件中存储数组值
- hibernate - 休眠 @OneToOne 映射
- python - 用Python中的字符串提取数据框中的最后一个数字
- javascript - 如何使用 JS 显示和隐藏我的响应式汉堡菜单