我试图在CSS中使用使用Client加载的图像,所以我使用CssResource编写代码,如下所示,对我不起作用
ClientBundle接口
public interface MyResources extends ClientBundle {
@Source("tab_off_LT.png")
DataResource image();
@Source("my.css")
MyCssResources css();
}CssResource接口
public interface MyCssResources extends CssResource{
String myImage();
}CSS文件
@url test1 image;
.myImage {
background: 'test1';
width: 50px;
}实现代码
RootLayoutPanel rp = RootLayoutPanel.get();
MyResources myr = (MyResources) GWT.create(MyResources.class);
myr.css().ensureInjected();
Label l = new Label("Test BackgroundImage");
l.setStyleName(myr.css().myImage());
rp.add(l);如果我在代码中的任何地方出错,想知道哪里出错了吗?
发布于 2012-11-17 10:26:55
@url定义了一个变量(在您的例子中名为test1)。代码中background的值是字符串文本,而不是对变量的引用:删除引号。
@url test1 image;
.myImage {
background: test1;
width: 50px;
}请参阅Resources
https://stackoverflow.com/questions/13429483
复制相似问题