Vaadin 将组件颜色设置为 hex 或 int 或 rgb
Vaadin set component color to hex or int or rgb
我目前正在和 Vaadin 打交道。
我看到我可以更改背景颜色,例如像这样的按钮:
cButton.getStyle().set("background","red");
但是如果我想像这样设置一个特定的颜色:#EAB251。怎么做到的?
此颜色可能会根据用户在 RGB-/HEX-/INT-color 选择器中的选择而改变。
您可以为 属性 使用任何有效的 CSS 值。所以 cButton.getStyle().set("background", "#EAB251")
和 cButton.getStyle().set("background", "rgb(234, 178, 81)")
应该有效。事实上,您发布的代码行有效,因为 red
是一个 CSS 颜色名称。
我目前正在和 Vaadin 打交道。
我看到我可以更改背景颜色,例如像这样的按钮:
cButton.getStyle().set("background","red");
但是如果我想像这样设置一个特定的颜色:#EAB251。怎么做到的?
此颜色可能会根据用户在 RGB-/HEX-/INT-color 选择器中的选择而改变。
您可以为 属性 使用任何有效的 CSS 值。所以 cButton.getStyle().set("background", "#EAB251")
和 cButton.getStyle().set("background", "rgb(234, 178, 81)")
应该有效。事实上,您发布的代码行有效,因为 red
是一个 CSS 颜色名称。