简体   繁体   English

Vaadin,应用自己的主题无效

[英]Vaadin, applying own theme doesn't work

I am trying to add custom theme to my Vaadin 7 project. 我正在尝试向Vaadin 7项目添加自定义主题。 I used the Vaadin plug-in theme creater, it created the necessary files and I included a simple background-color setting to my table, but even though reindeer theme is included it doesn't seem to work. 我使用了Vaadin插件主题创建器,它创建了必要的文件,并且在表中添加了一个简单的背景色设置,但是即使包含了驯鹿主题,它似乎也不起作用。 After I apply my theme with @Theme() annotation on my UI class my table disappears and I get this (without the custom theme it looks fine): 在我的UI类上应用带有@Theme()批注的主题后,我的表消失了,并且得到了它(没有自定义主题,看起来不错):

在此处输入图片说明

I read the part of the Book of Vaadin that describes this ( https://vaadin.com/book/-/page/themes.creating.html ) but it still doesn't work for me. 我阅读了Vaadin书中描述此内容的部分( https://vaadin.com/book/-/page/themes.creating.html ),但它对我仍然无效。 I read this part: https://vaadin.com/book/-/page/themes.html#figure.themes.theme-contents and it shows reindeer should be under themes, but it says I have to include the vaadin-themes.jar and it will work fine. 我阅读了这一部分: https : //vaadin.com/book/-//page/themes.html#figure.themes.theme-contents ,它显示驯鹿应该属于主题,但是它说我必须包括vaadin-themes .jar,它将正常工作。 I did add it, my filestructure looks like this: 我确实添加了它,我的文件结构如下所示:

在此处输入图片说明

airlinedb_customtheme.scss file's code: airlinedb_customtheme.scss文件的代码:

@import "../reindeer/reindeer.scss";
@mixin airlinedb_customtheme {
  @include reindeer;
  .v-table {
    background-color: red;
  }
}

and my theme's styles.scss: 和我主题的styles.scss:

@import "airlinedb_customtheme.scss";
.airlinedb_customtheme {
   @include airlinedb_customtheme;
 }

What am I missing? 我想念什么? It looks like to me that reindeer style isn't included but I have no idea why. 在我看来,不包括驯鹿风格,但我不知道为什么。

EDIT:Furthermore, how can I give background color for my button and my table-row? 编辑:此外,如何给按钮和表格行赋予背景颜色?

尝试从vaadin jar文件中提取VAADIN / themes / reindeer目录,并将其添加到WebContent内的VAADIN / themes /目录中,这样将以静态方式提供您的theme / css,并且@import应该可以正常工作。

That's just a suggestion but try the names without underlines.I have never seen before scss names with underlines. 这只是一个建议,但是尝试不带下划线的名称。我从未见过带下划线的scss名称。

Like this: 像这样:

airlinedbCustomtheme

EDIT: 编辑:

Vaadin book-table Vaadin书桌

Read this at section CSS style rules. 在CSS样式规则一节中阅读此内容。

.v-table {}
  .v-table-header-wrap {}
    .v-table-header {}
     .v-table-header-cell {}
      .v-table-resizer {} /* Column resizer handle. */
       .v-table-caption-container {}
 .v-table-body {}
  .v-table-row-spacer {}
   .v-table-table {}
    .v-table-row {}
     .v-table-cell-content {}

To change the background color of a button then you have to remove the button wrapper and background image first: 要更改按钮的背景色,则必须先删除按钮包装纸和背景图片:

.v-button .v-button-wrap { 
  background-image: none !important; 
} 
.v-button { 
  background-image: none !important; 
}

Don't forget to use the !important modifier for the CSS! 不要忘记对CSS使用!important修饰符!

.v-table { 
  background-color: red !important; 
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM