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

查看:34
本文介绍了如何将 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;
}

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

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