GWT – 设置全局CSS样式的最佳方式

HTML教程 2026-03-21
我们正在使用GXT和GWT,每个基本小部件都有一个CSS文件. GWT中拥有全局css风格的最佳方式是什么?

例如

global.css.backgroundBorder {   border-style: solid;   border-width: 2px;   border-radius: 3px;}

myWidget.css

@backgroundBorder
我同意.另外我会在上面的AppClientBundle中包含一个接口.

public interface AppClientBundle extends ClientBundle {  public static final AppClientBundle INSTANCE = GWT.create(AppClientBundle.class);  @Source({ "css/template/global.css" })  MyStyle css();  public interface MyStyle extends CssResource {    String backgroundBorder();  }}

这使您可以以这种方式设置样式的样式:

Widget.setStylePrimaryName(AppClientBundle.INSTANCE.css().backgroundBorder());

希望有帮助……