您好,我正在尝试在 vaadin
组件上定义我的自定义样式。我有一个带有 styles
的 html 文件,它看起来像这样:
<link rel="import" href="../bower_components/vaadin-lumo-styles/color.html">
<link rel="import" href="../bower_components/vaadin-lumo-styles/typography.html">
<dom-module id="css-style-example" theme-for="vaadin-button">
<template>
<style include="vaadin-button-default-theme">
.card {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
width: 40%;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,50);
transform: scale(1.05, 1.05)
}
</style>
</template>
</dom-module>
这是gradle
元素,这个文件
位于/src/main/resources/frontend/styles。
我正尝试在我的 button
组件上使用此 style
,如下所示:
@HtmlImport("frontend://styles/shared-styles.html")
public class BasePageView extends VerticalLayout {
.
.
.
homeButton.setClassName("card");
}
但我不知何故无法让这东西工作。我是 css
的新手,所以请原谅我的任何愚蠢错误。
我在 github 上搜索了一些示例,但我有点迷路了,如果有人能向我解释我如何定义 style
,我将不胜感激,比方说, vaadin
流 button
?感谢您的帮助。
最佳答案
使用 <custom-style>
代替 dom 模块(以 vaadin 按钮为目标)相反,它用于全局样式:
<custom-style>
<style>
.card {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
width: 40%;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,50);
transform: scale(1.05, 1.05)
}
</style>
</custom-style>
有关样式化 Vaadin 组件的更多信息,请阅读这些指南:https://github.com/vaadin/vaadin-themable-mixin/wiki
关于java - Vaadin 流自定义样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50174807/