2012-02-05 59 views
3

我正在嘗試使用自定義顏色和圖像/文本創建按鈕。添加顏色和圖像/文字很容易,但現在我有垂直對齊的問題。 「文本對齊:中心」幫助我進行水平對齊,但沒有垂直運氣。GWT PushButton圖像/文本對齊

<ui:style> 
    .gwt-b { 
     margin: 50px; 
     height: 23px; 
     width: 60px; 
     color: #fff; 
     font-size: 12px; 
     font-family: arial, sans-serif; 
     text-align: center; 
     vertical-align: middle; 
     background: -webkit-linear-gradient(top,#4d90fe,#357ae8); 
     border: 1px solid #3079ED; 
     outline-color: #3079ED; 
     outline-width: 3px; 
    } 
</ui:style> 

<g:HorizontalPanel> 
    <g:PushButton ui:field='pushButton' enabled='true' addStyleNames="{style.gwt-b}"> 
     <g:upFace image="{res.search}"> 
     </g:upFace> 
    </g:PushButton> 

    <g:PushButton ui:field='pushButton2' enabled='true' addStyleNames="{style.gwt-b}"> 
     <g:upFace> 
      <b>click me</b> 
     </g:upFace> 
    </g:PushButton> 
<g:HorizontalPanel> 

這裏是我已經有了:

enter image description here

回答

1
.gwt-b {   
    ... 
    line-height: 12px; 
    ... 
} 
+1

它有助於文本的情況下,而不是圖像 – Melena 2012-02-05 17:06:02

0

IE8 +

.gwt-b { 
    ... 
    display: table-cell; 
    vertical-align: middle; 
    ... 
}