Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT ImageResource accessed within a CSS property?

Tags:

css

gwt

The Google/GWT example of creating an ImageResource is understood:

interface MyResources extends ClientBundle {   @Source("image.png")   ImageResource image();    @Source("my.css");   CssResource css(); }  @sprite .myImage {   gwt-image: 'image'; } 

I understand how to use ImageResources and apply style names, however...

In my application, I have multiple themes that are applied to various widgets using CSS and deferred binding. So I have defined a CSS rule ('background') that I would like to use the .myImage class, but it does not do anything:

background {     background-attachment: fixed;     background-image: .myImage;  //??  This is the question!     background-size: contain } 

What is the syntax for using the .myImage class within the 'background' CSS property? It seems I should be able to specify the .myImage class as the argument for background-image.

Edit: Did some more research and found the correct syntax to do this using a DataResource.

MyClientBundle extends ClientBundle {      //Background Image     @Source("resources/background.png")     DataResource backgroundImage();  } 

(mypanel.css)

@url background backgroundImage;  .myPanel {     border-radius: 0px;     background-color:#ffffff;     opacity:0.6;     background-image: background; } 
like image 607
chris Avatar asked Jun 26 '12 14:06

chris


1 Answers

If you add "myImage" as style name to any widget, it will set those widgets' background...

like image 173
Umit Avatar answered Sep 29 '22 14:09

Umit