给a标签设置设置字体大小时却不能居中呢?
来源:2-2 页面顶部的开发(1)
慕无忌2027147
2021-10-02 16:03:58
问题描述:
为什么给 li设置字体大小可以使垂直居中, 给a标签设置设置字体大小时却不能居中呢?
相关代码:
.site-head {
height: 150px;
}
.site-head .topbar {
height: 32px;
background-color: #2a2a2a;
line-height: 32px;
color: white;
}
.site-head .topbar .center-wrap {
}
.site-head .topbar .center-wrap .shortCut-links {
float:left;
}
.site-head .topbar .center-wrap .shortCut-links ul {
}
.site-head .topbar .center-wrap .shortCut-links > ul > li {
float: left;
margin-right: 18px;
font-size: 12px;
}
.site-head .topbar .center-wrap .shortCut-links > ul > li .have-menu {
padding-right: 12px;
}
.site-head .topbar .center-wrap .shortCut-links > ul > li a {
color: white;
}
.site-head .topbar .center-wrap .shortCut-links > ul > li.have-menu{
padding-right: 12px;
}
1回答
好帮手慕久久
2021-10-06
同学你好,a标签是行内元素,默认垂直方向并不是居顶对齐,因此给a设置字体大小时,a实际的高度可能与预期不一样,从而导致文字垂直方向的位置有变化。因此,建议不要给a设置字体大小。
祝学习愉快!
相似问题