样式锚内的中心文本

时间:2014-02-22 00:31:14

标签: css html5

我正在使用“a”标签并将其设置为使其更大一些,但我似乎无法让文本在中间对齐。我尝试添加填充,但这只是使它更大。现在文本在左上角但我想要它死在中心,任何想法?

<a href="#">text</a>
a {
    width: 196px;
    height: 64px;
    background-color: blue;
    border: 0px none;
    font-size: 20px;
    color:white;
}

1 个答案:

答案 0 :(得分:1)

a {
    width: 196px;
    height: 64px;
    background-color: blue;
    border: 0px none;
    font-size: 20px;
    color:white;
    display:inline-block; /* if more items are in line */
    line-height:64px; /* if one line of text is in question */
    text-align:center;

}

http://jsfiddle.net/K4q6H/

相关问题