如何将 CSS 用于 Vaadin 组件?
我似乎看到了一些例子,人们回答了如何通过添加 CSS 代码从组件中获取某些特定行为的问题,但似乎没有人解释如何使用该 CSS 代码将其连接到 Java 组件...
I seem to be seeing examples, where people answer to questions how to get some specific behavior from components by adding CSS code, however nobody seems to explain how to use that CSS code to connect it to Java components...
.v-table-body{
overflow: hidden !important;
}
例如,我如何在我创建的表上使用此代码?
How do I use for instance this code on my table that I create?
Table table = new Table(caption);
table.addContainerProperty("Visit ID", Long.class, null);
推荐答案
您可以创建自己的自定义主题.请参阅 https://vaadin.com/book/-/page/themes.creating.html 如何做到这一点.
在这个主题中,您有一个 css 样式表,您可以在其中放置您的规则.
You can create you own custom theme. See https://vaadin.com/book/-/page/themes.creating.html how to do that.
In this theme you have a css style sheet where you can put your rules.
在每个组件上,您都可以使用 addStyleName 函数添加额外的类名:
On every Component you can use the addStyleName function to add an additional class name:
Table table = new Table("MyCaption");
table.addStyleName("mystyle");
现在您可以在样式表中使用它:
Now you can use this in your style sheet:
@import "../reindeer/styles.css";
.mystyle{
overflow: hidden !important;
}
相关文章