比如:
a
{display:block;
background-color:red;
width:120px;
height:50px;
text-align:center;
padding:6px;
text-decoration:none;
}
这是文字
如果不加height:50px;这句,文字在红色框里就是居中对齐的,加了这句,文字在框里就偏上。为什么?不是说padding给一个值可以让四边都对称的吗? 如果我一定要设定框高度,那么用什么办法实现文字在空间里居中?
回复讨论(解决方案)
a
{display:block;
background-color:red;
width:120px;
height:50px;
line-height:50px;
text-align:center;
padding:6px;
text-decoration:none;
}
查看更多关于关于padding设置的问题_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did114246