如何在 uibinder (GWT) 中为 ClientBundle 资源设置背景图像
如何在不使用的情况下将 uibinder/java 中的背景图像设置为 ClientBundle 中的图像:
obj.getElement().getStyle().setBackgroundImage("url("+Images.INSTANCE.bg().getURL()+")");
因为这在 IE 中不起作用(FF 也可以)。 我想我应该使用 css @url 直接在 uibinder 中设置背景图像或...
(我使用的是 GWT 2.0.3)
问候
How to set background image in uibinder/java to an image in ClientBundle without using:
obj.getElement().getStyle().setBackgroundImage("url("+Images.INSTANCE.bg().getURL()+")");
Because this doesn't work in IE (FF is OK).
I think I should set the background image directly in uibinder with css @url or ...
(I am using GWT 2.0.3)
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文档对此进行了解释:)(请注意,UiBinder 在内部使用
CssResource
,因此所有适用于CssResource
的内容也适用于您在 UiBinder 的
中定义的 CSS 样式)The docs explain this :) (note that internally UiBinder uses
CssResource
, so all that applies toCssResource
, applies to the CSS styles you define in UiBinder's<ui:style>
too)ImageResource 使用数据 URL 和 spriting。遗憾的是,旧版本的 IE 都不能很好地支持这两者。根本不支持数据 Url,并且在 ie 7 上 - 整个精灵图像的新副本用于图像的每个剪辑外观。因此,如果您有一个包含 100 个图标的精灵并在 100 个地方使用它,则 IE 将消耗该图像 100 倍的内存。
如果可以的话,尝试摆脱非常旧的 IE。
ImageResource uses Data Urls and spriting. Sadly, older versions of IE support neither of these well. Data Url is not supported at all and on i.e. 7- a new copy of the entire sprite image is used for every clipped appearance of the image. So, if you have a sprite with 100 icons and use it in 100 places, IE will consume the memory of 100x that image.
Try to get away from really old IE if you can.