我正在使用CSS和按钮,我希望文本历史记录位于按钮的中心,但它出现在单元格的顶部。我怎样才能将它垂直插入中间?
CSS
a.button {
background: url(button.png) no-repeat 0 0;
width: 150px;
height: 62px;
display: block;
}
HTML
<td align="center" valign="middle" >
<a href="history.htm" class="button"/><b>HISTORY</b></a>
</td>
答案 0 :(得分:3)
如果它只有一行文字,那么我通常会使用line-height
= height
a.button {
background: green;
width: 150px;
height: 62px;
display: block;
line-height: 62px;
text-align: center;
}
&#13;
<a href="history.htm" class="button"/><b>HISTORY</b></a>
&#13;
答案 1 :(得分:1)
使用&#34;垂直对齐:中间;&#34;在你的a.button css规则。