我在GWT中的CssResource几乎没有问题。我想改变AbsolutePanel和标签的样式,但它不会运行。当我使用setStyleName方法添加样式类时,没有任何事情发生。GWT - CssResource does not run
在这个片段中的代码,我使用资源:
public CustommerView() {
MyResource cssResource = GWT.create(MyResource.class);
MyCss myCss = cssResource.css();
AbsolutePanel basePanel = new AbsolutePanel();
initWidget(basePanel);
basePanel.setStyleName(myCss.rootPanel());
Label label = new Label();
label.setText("Im label");
label.setStyleName(myCss.label());
basePanel.add(label);
}
这是我的界面延伸CssResource:
public interface MyCss extends CssResource {
/**
* Method for return command button class name
* @return command button class name
*/
public String rootPanel();
public String label();
}
这是我的CSS文件,这是旁边MyCss界面上的文件系统:
.rootPanel {
position:absolute !important;
top:0px;
left:0px;
background-color:yellow !important;
height: 20px !important;
width: 18px !important;
}
.label {
color:red;
}
Custommer视图是GWT Composite。当我想要移动视图时,我简单地在演示者中调用RootPanel.get(“mainArea”).add(view.asWidget)。 mainArea是div元素。
当我在web inf的css文件中粘贴css类时,一切运行正常。有人能给我点如何解决这个问题?谢谢。
[CssResource中定义的CSS问题]的可能的重复(http://stackoverflow.com/questions/10262089/troubles-with-css-defined-in-cssresource) –