CSS动态注入Vaadin问题,怎么解决
发布网友
发布时间:2023-08-13 22:14
我来回答
共1个回答
热心网友
时间:2023-08-27 17:58
I am struggling with some minor layout changes in vaadin which has to be done on Java AND Css side.
Everytime I need to adjust a layout thing like padding-top, background color or bold text of one component I need to set the style via Java code too:
userLink.setStyleName("textbold");
The changes in my styles.css (under VAADIN/themes/app/) would then be:
@import "../runo/styles.css";
.textbold {
font-weight: bold;
}
...
Is this the correct way of changing the CSS or is there another way? Can I do this without affecting the Java code?
解决方案
This is the way to go.
You would do exactly the same in HTML. You define a class name in a CSS file and associate the class name with your HTML element. The other way would be to directly set the style in JAVA (like you could do it directly in HTML) but this is not suggested.
本文地址:IT屋 » What is the method of choice to adjust CSS changes in vaadin?