如何在 uibinder (GWT) 中为 ClientBundle 资源设置背景图像

发布于 2024-09-14 19:14:33 字数 284 浏览 8 评论 0原文

如何在不使用的情况下将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹿港小镇 2024-09-21 19:14:33

文档对此进行了解释:)(请注意,UiBinder 在内部使用CssResource,因此所有适用于 CssResource 的内容也适用于您在 UiBinder 的 中定义的 CSS 样式)

The docs explain this :) (note that internally UiBinder uses CssResource, so all that applies to CssResource, applies to the CSS styles you define in UiBinder's <ui:style> too)

〆凄凉。 2024-09-21 19:14:33

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文