如何覆盖 GWT 2.3 中的默认样式?
这个问题以前曾被问过,但针对旧版本的 GWT。我正在使用提供的“干净”主题,但我想覆盖一些样式(字体等)。不推荐使用链接标记来链接 HTML 文件中的样式表,就像在 gwt xml 文件中使用样式表标记一样 (http://code.google.com/webtoolkit/doc/latest/DevGuideUiCss.html#cssfiles)。那么如何将 css 文件与您的项目关联起来呢?我没有使用 UIBinder。
This question has been asked before, but for older versions 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从您引用的同一页面:
但我所做的是为“旧”样式创建一个特定的 CSSResource。该资源不在代码中使用,但专门用于在开发过程中将所有“旧”样式放入一个 css 文件中。通常,它应该只包含“旧”GWT 样式,而不是您自己通过字符串作为类名设置的样式。这些最好通过 CssResource 技术。与通过链接 rel 包含普通样式的区别在于,资源中的样式是注入的,而不是通过单独的样式表包含的。代码示例:(
也不要忘记注入此 css 资源)。
请在此处查看有关严格范围界定的更多信息:http://code.google.com/ webtoolkit/doc/latest/DevGuideClientBundle.html#Strict_scoping
From the same page you're refering to:
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:
(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
谷歌似乎希望我们使用 ClientBundle &从现在开始,CssResource。
It seems like google wants us to use ClientBundle & CssResource from now on.
我认为解决此问题的最佳方法是从 GWT jar 文件复制“干净”主题的 CSS 文件。禁用应用程序中的主题,然后自定义该 CSS 文件的您自己的版本。
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.