我如何使用CSS Vaadin组件? [英] How can I use CSS for Vaadin components?

查看:159
本文介绍了我如何使用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;
}

如何在我创建的表上使用这个代码? / p>

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

这篇关于我如何使用CSS Vaadin组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆