简体   繁体   English

GWT如何在图像资源上添加CSS样式

[英]GWT how to add css style on Image Resource

I am using GWT. 我正在使用GWT。 I have an Image Resource object. 我有一个图像资源对象。 for example, 例如,

 ImageResource image = ClientResources.of().images().icon();

How can I add some css styles on this image. 如何在此图像上添加一些CSS样式。 Since this is ImageResource, not the Image object, I cannot use image.addStyleName(). 由于这是ImageResource,而不是Image对象,因此无法使用image.addStyleName()。 I am not using ui-binder. 我没有使用ui-binder。 So how could I achieve this? 那么我该如何实现呢?

Because I am newb in GWT, if you answer could provide some codes, that would be more clear and really appreciated. 因为我是GWT的新手,所以如果您的回答可以提供一些代码,那将更加清楚并且非常感谢。

Best Regards. 最好的祝福。

How are you displaying the image? 您如何显示图像? You can't perform CSS operations on an ImageResource directly, but neither can you display it directly. 您不能直接在ImageResource上执行CSS操作,但是也不能直接显示它。 You have to stick it in an Image , ImageResourceCell , or some other object, all of which are able to be styled. 您必须将其粘贴到ImageImageResourceCell或某些其他对象中,所有这些对象可以进行样式设置。 So you'd want to style the renderer, not the ImageResource itself. 因此,您需要设置渲染器的样式,而不是ImageResource本身的样式。

For example: 例如:

ImageResource imageResource = ClientResources.of().images().icon();
Image image = new Image(imageResource);
image.addStyleName("someCoolStyle");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM