开发者

How to override default styles in GWT 2.3?

This question has been asked before, but for older versio开发者_开发技巧ns of GWT. I'm using the "clean" theme that's provided, but I'd like to override some styles (fonts and such). Linking a stylesheet in the HTML file with link tags is deprecated, as is using a stylesheet tag in the gwt xml file (http://code.google.com/webtoolkit/doc/latest/DevGuideUiCss.html#cssfiles). How do you associate a css file with your project, then? I'm not using UIBinder.


From the same page you're refering to:

If you do not care about sharing or re-using your module then you can just use the standard HTML link rel stuff in the host page.

But what I do is create a specific CSSResource for the 'old' styles. This resource is not used in code, but is specific to place all 'old' styles in and have them in one css file during development. Typically this should only contain 'old' GWT styles and not you're own set via a string as class name. Those should preferable go via the CssResource technique. A difference with plain style inclusion via link rel is that the styles in the resource are injected and not included via a separate stylesheet. Code example:

interface Resources {
  @Source("notstrict.css")
  @CssResource.NotStrict
  CssResource notStrictCss();
}

(also don't forget to inject this css resource).

See more on strict scoping here: http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#Strict_scoping


It seems like google wants us to use ClientBundle & CssResource from now on.


I think the best way to go about this is to copy the "clean" theme's CSS file from the GWT jar file. Disable the theme in your application and just customise your own version of that CSS file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜