2
我使用gwt在td內顯示動態圖像,圖像來自圖像包,但它顯示gwt在編譯期間在整個td內形成的整個大圖像,而不是從該圖像中顯示特定部分大的形象。我不知道我在這裏錯過了什麼......問題是圖像將被動態地添加和選擇,並且每次添加圖像時我都無法定義一個css。如果你們中的任何人都可以幫助我。這裏是我的代碼GWT背景圖片
我的表格單元的UiBinder的像中定義....
<ui:style>
.colourPickerCell {
background-repeat:no-repeat;
}
</ui:style>
<tr>
<td class="{style.colourPickerCell}" ui:field="colourPreviewSlot" rowspan="3" width="50%"></td>
</tr>
主持人類的內部功能:
public void newColorSelected(Image patternImage) {
Style patternImageStyle = patternImage.getElement().getStyle();
Style style = getColourPreviewSlot().getStyle();
style.setWidth(patternImage.getWidth(), Unit.PX);
style.setBackgroundImage(patternImageStyle.getBackgroundImage());
style.setLeft(-patternImage.getOriginLeft(), Unit.PX);
style.setTop(-patternImage.getOriginTop(), Unit.PX);
style.setHeight(patternImage.getHeight(), Unit.PX);
}
當我調試我的代碼我得到的HTML的patternImage對象:
<img id="..." style="backgrond:url(....) no-repeat -149px 12px;"/>
最好的問候,