2012-09-05 70 views
0

我在gwt應用程序中使用了一個LayoutPanel,其中包含兩個Button。 LayoutPanle的高度爲35px;而按鈕的高度爲25px;我想垂直對齊面板中間的按鈕。就像我已經嘗試過的那樣,沒有任何常見的造型方法似乎可以處理它。在面板造型或按鈕樣式上設置垂直對齊:中間,按鈕保持頂部對齊。在這種情況下,最終如何將按鈕置於中間,而不是在LayoutPanel中爲每個Button包裝一個Horizo​​ntalPanel並在Horizo​​ntalPanel上應用verticalAlignment?這是我在UiBinder的代碼:LayoutPanel中的垂直對齊

<g:LayoutPanel styleName="{style.buttonsBar}"> 
      <g:layer left="30px" width="70px"> 
       <g:Button ui:field="createButton" styleName="{style.crdelButton}">Create</g:Button> 
       </g:layer> 
       <g:layer right="30px" width="70px"> 
        <g:Button ui:field="deleteButton" styleName="{style.crdelButton}">Delete</g:Button> 
       </g:layer> 
     </g:LayoutPanel> 

回答

0

如果面板總是35px高,你有兩個選擇:

(1)上的按鈕設置保證金

保證金:5px的0;

(2)將以下樣式到您的LayoutPanel:

的line-height:35px;