GWT theme style overrides my css style

前端 未结 6 1698
陌清茗
陌清茗 2020-11-27 05:21

I have some html files with their own css. I want to use them in a gwt application so i copied the html and the css files in the application.

The problem is when i o

6条回答
  •  醉话见心
    2020-11-27 05:51

    This post on the GWT mailing list describes an alternative solution. You have to create a new ClientBundle which references your CSS file:

    import com.google.gwt.core.client.GWT;
    import com.google.gwt.resources.client.ClientBundle;
    import com.google.gwt.resources.client.CssResource;
    
    public interface Resources extends ClientBundle {
    
          public static final Resources INSTANCE = GWT.create(Resources.class); 
    
          @Source("style.css")
          @CssResource.NotStrict
          CssResource css();
    }
    

    And then inside your onModuleLoad() method you have to inject the CSS file:

    public class YourApp implements EntryPoint {
    
        public void onModuleLoad() {
            //...
            Resources.INSTANCE.css().ensureInjected(); 
            //...
        }
    

    In my opinion this is the cleanest and easiest way to override the styles.

提交回复
热议问题