[英]GWTP (Java): Apply CSS style on div element
I am using GWTP and I am trying to include boxcontainer
style in a div element. 我正在使用GWTP,并且试图在div元素中包含
boxcontainer
样式。 However, it is not working. 但是,它不起作用。 Seems that the CSS is not properly link?
似乎CSS没有正确链接? Any ideas?
有任何想法吗? Thanks
谢谢
resources/Thumbnail.css 资源/Thumbnail.css
.boxcontainer {
width:100%;
height:900px;
border:0px solid #000;
padding-top:20px;
padding-bottom:5px;
padding-right:15px;
padding-left:15px;
margin: 0px auto -1px auto;
background: #000000;
}
Thumbnail.ui.xml (HTML template) Thumbnail.ui.xml(HTML模板)
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field="res" type="com.gw.aaaa.client.presenter.dashboard.ThumbnailResources"/>
<div ui:field='container' class="{res.style.boxcontainer}"></div>
</ui:UiBinder>
ThumbnailResources.java ThumbnailResources.java
public interface ThumbnailResources extends ClientBundle {
public static final ThumbnailResources INSTANCE = GWT.create(ThumbnailResources.class);
@Source("resources/Thumbnail.css")
ThumbnailStyle style();
}
ThumbnailStyle.java ThumbnailStyle.java
public interface ThumbnailStyle extends CssResource {
String boxcontainer();
}
You need to inject that your styles in order to be referenced. 您需要注入您的样式以便被引用。 Use:
采用:
ThumbnailResources.INSTANCE.style().ensureInjected();
Only when using <ui:style>
the generated CssResource
is also automatically injected. 仅当使用
<ui:style>
,也会自动注入生成的CssResource
。 With <ui:with>
you are referencing an external CssResource
, but you need to take care to inject it (and of course to instantiate the relative ClientBundle
as you already did). 使用
<ui:with>
您引用的是外部CssResource
,但是您需要注意注入它(当然也要像实例化那样实例化相对的ClientBundle
)。
Instead of 代替
<div ui:field='container' class="{res.style.boxcontainer}">
just use: 只需使用:
<div ui:field='container' styleName="boxcontainer">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.