I have a cla开发者_高级运维ss that references a background image (and I don't want to upgrade to using imagebundles) so I need to print the "base module url" before my image url. How can I achieve this?
background: #BDE5F8 url("image/info.png") no-repeat 2px center;
You could always add a static function somewhere:
public static String getBackgroundUrl(){
return com.google.gwt.core.client.GWT.getModuleName() + "/images/background.png";
}
And in your CSS
@eval BG_URL com.yourclass.getBackgroundUrl();
.myBackground { background-url:BG_URL; }
Including images in your ClientBundle really is the way to go. But then again, you've already mentioned that you're not going to do that.
Instead, consider using a value function to get the value of GWT.getModuleBaseURL()
:
.something {
background: #BDE5F8 value('com.google.gwt.core.client.GWT.getModuleBaseURL', '/info.png') no-repeat 2px center;
}
精彩评论