选择什么方法来调整vaadin中的CSS变化? [英] What is the method of choice to adjust CSS changes in vaadin?

查看:492
本文介绍了选择什么方法来调整vaadin中的CSS变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



每次我需要调整一个布局的东西,如padding-一个组件的顶部,背景颜色或粗体文本我需要通过Java代码设置样式:

  userLink.setStyleName textbold); 

我的styles.css中的更改(在VAADIN / themes / app /下) / p>

  @import../runo/styles.css; 

.textbold {
font-weight:bold;
}
...

这是更改CSS的正确方法或有另一种方式?我可以这样做而不影响Java代码吗?

解决方案

这是要走的路。



您会在HTML中完全相同。您在CSS文件中定义类名,并将类名与您的HTML元素相关联。另一种方法是直接在JAVA中设置样式(就像你可以直接在HTML中做的那样),但这不是建议。


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.

这篇关于选择什么方法来调整vaadin中的CSS变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆