I want to set the CSS background property of a Vaadin Flow Div element with text as content.
Direct CSS property manipulation works fine
div.getStyle().set("background-color","yellow");
Next step - CSS class injection, but no method is working for me. What is wrong?
with best regards
Peter
/* frontend/styles/test.css */
.blog {
background-color:yellow;
}
Inside the main class no method for class injection is working
@StyleSheet("./styles/test.css")
@Route("")
public class MainView extends VerticalLayout {
......
Div f = new Div();
f.getElement().setProperty("innerHTML", loreIpsum);
// div.getStyle().set("background-color","yellow"); - WORKS FINE
f.setClassName("blog"); // DO NOT WORK
// f.getElement().setAttribute("class","blog"); // DO NOT WORK
// f.getElement().getClassList().add("blog"); // DO NOT WORK
.....