我希望我的登录页面在正文中有背景图片。这是我到目前为止所拥有的:
public interface MyResources extends ClientBundle {
public static final MyResources INSTANCE = GWT.create(MyResources.class);
@Source("css/login.css")
public MyLoginCssResource loginCss();
@Source("css/GWT_App.css")
public CommonCss commonCss();
@Source("img/logo.png")
@ImageOptions(repeatStyle = RepeatStyle.Both)
ImageResource backgroundImage();
}
public interface CommonCss extends CssResource {
String body();
}
.body {
background-color: white;
gwt-image: 'backgroundImage';
}
如果我已经引用了 loginCss,如何在我的 ui.xml 文件中引用 commonCSS?
<ui:with field='res' type='client.resources.MyResources' />
<g:HTMLPanel addStyleNames="{res.loginCss.maindiv}">
</g:HTMLPanel>
</ui:UIBinder>
另外,如何在 ui.xml 文件中为 body 标签设置样式?
最佳答案
How do I reference the commonCSS in my ui.xml-file if I already have the loginCss referenced?
<g:HTMLPanel addStyleNames="{res.loginCss.maindiv} {res.commonCss.body}"/>
and also, how can I set a style for the body tag in a ui.xml-file?
据我所知,您无法从 ui.xml 文件访问正文。 有几种方法可以仅在登录页面中使用此背景。 最简单的就是将所有页面包裹在一个容器 block 中
<g:FlowPanel addStyleNames="{res.commonCss.body}">
<g:HTMLPanel addStyleNames="{res.loginCss.maindiv} "/>
</g:FlowPanel>
因此在登录页面的导航中 - 背景不会停留在那里。
如果你想要永久效果 - 你可以在你的 index.html 文件中添加 css,作为 body 标签的常规 css
关于css - gwt 2.7.0 body 背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34793198/