比如:
这是文字
如果不加height:50px;这句,文字在红色框里就是居中对齐的,加了这句,文字在框里就偏上。为什么?不是说padding给一个值可以让四边都对称的吗? 如果我一定要设定框高度,那么用什么办法实现文字在空间里居中?
回复讨论(解决方案)
a
{display:block;
background-color:red;
width:120px;
height:50px;
line-height:50px;
text-align:center;
padding:6px;
text-decoration:none;
}