How can I use CSS for Vaadin components?

时光总嘲笑我的痴心妄想 提交于 2020-01-01 10:16:15

问题


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);

回答1:


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.

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;
}


来源:https://stackoverflow.com/questions/14274816/how-can-i-use-css-for-vaadin-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!