1、利用flex布局中的垂直居中属性实现垂直居中
HTML
<div class="nav">
<a><span>新闻资讯</span></a>
<a><span>产品中心</span></a>
<a><span>联系我们</span></a>
</div>
CSS
.nav
{
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.nav a
{
width: 1.75rem;
height: .6rem;
font-size: .28rem;
color: #000;
margin-right: .03rem;
display: flex;
align-items: center;
justify-content: center;
}
2、不直接设置line-height=height,而是设置
line-height:normal;
padding:10px 0;