简体   繁体   English

样式标签字体大小

[英]Style label font size

I'm trying to make H3 label, at this point I use built-in Vaadin theme - ValoTheme.This is how i create new label: 我正在尝试制作H3标签,这时我使用内置的Vaadin主题-ValoTheme。这就是我创建新标签的方式:

Label label = new Label();
label.setCaption("myLabel");
label.setStyleName(ValoTheme.LABEL_H3);

But for some reason, label keeps unstyled. 但是由于某种原因,标签没有样式。 The question is - how i could stylish Label without using CSS? 问题是-如何在不使用CSS的情况下实现Label的时尚?

Thanks 谢谢

PS UI class has been annotated with @Theme(ValoTheme.THEME_NAME) PS UI类已使用@Theme(ValoTheme.THEME_NAME)注释

Update: Making primary button with ValoTheme styling as described above, everything works perfectly. 更新:使用如上所述的ValoTheme样式制作主按钮,一切正常。

It took for a while to investigate and found solution that fits me best. 经过一段时间的调查,找到了最适合我的解决方案。 The issue has been related to 'label.setCaption(caption);' 问题与“ label.setCaption(caption);”有关。 method, which set components caption, but it denied object customizations. 方法,该方法设置了组件标题,但拒绝了对象自定义。

Thanks to @André Schild for suggestion. 感谢@AndréSchild的建议。 So i tested these two small solutions and they worked fine: 因此,我测试了这两个小型解决方案,它们运行良好:

Label label = new Label(caption);
label.setStyleName(ValoTheme.LABEL_H3);

and

Label label = new Label(caption);
label.addStyleName(ValoTheme.LABEL_H3);

I hope it helps someone 我希望它可以帮助某人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM