1
所以,关于这个问题。 我使用Vaadin 7.4.3。我想使用声明式用户界面,但我没有正确的方式使用CSS。Vaadin声明性用户界面与CSS
例如,我有映射MainView.html文件:
<!DOCTYPE html>
<html>
<head>
<meta name="package-mapping" content="auth:my.widget.package.web.main.auth" />
<link href="./styles/common.css" rel="stylesheet" type="text/css">
</head>
<body>
<v-vertical-layout size-full style-name="marginTop">
<auth-login-panel :right/>
</v-vertical-layout>
</body>
</html>
Java映射:
@Theme("valo")
@Widgetset("my.package.MyAppWidgetset")
public class MainView extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MainView.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
DesignContext context = Design.read(getClass().getResourceAsStream("MainView.html"), null);
setContent(context.getRootComponent());
}
}
简单的CSS(common.css),用于测试:
#marginTop {
margin-top: 20px;
}
.marginTop {
margin-top: 20px;
}
但是... CSS不起作用。 任何想法?
请问您能更具体些什么“不成功”是什么意思?是实际加载的CSS(见你的萤火虫,...)。接下来检查,如果该类甚至应用于生成的HTML,并且没有其他样式覆盖它。 – cfrick