2012-07-21 93 views
2

我認爲line-height會垂直居中對齊文本。但是這不是我的按鈕。爲什麼?如何垂直居中對齊按鈕內的文字?

該文本在FF,Opera和Safari中對齊。

Her is my fiddle

<button class="get_discount_rate">Button</button> 
button { 
    font-family: Arial, Helvetica, sans-serif; 
    font-weight: normal; 
    color: #444; 
    min-width: 90px; 
    height: 24px; 
    line-height: 24px; 
    margin: 5px 10px; 
    background-color: #fdfdfd; 
    border: 1px solid #cdcdcd; 
    cursor: pointer; 
    border-radius: 3px; 
} 
+0

行高:汽車; – jm666 2012-07-21 22:37:07

+0

或更好,然後,只需從css規則中刪除行高屬性 – asprin 2012-07-21 23:15:27

+1

是的,謝赫Heera只是證明了它:) – Steven 2012-07-21 23:15:59

回答

3
垂直

中心對齊內部button(在Chrome測試,FF,Safari瀏覽器,Opera和IE8)文本

button { 
    font-family: Arial, Helvetica, sans-serif; 
    font-weight: normal; 
    color: #444; 
    min-width: 90px; 
    padding:5px; 
    margin: 5px 10px; 
    background-color: #fdfdfd; 
    border: 1px solid #cdcdcd; 
    cursor: pointer; 
    border-radius: 3px; 
}​ 

DEMO.

+0

簡單,因爲:) – Steven 2012-07-21 23:15:23

+0

我認爲是這樣的::-) – 2012-07-21 23:16:13