如何使用空字符串设置 Vaadin 标签的宽度 [英] How to set width for Vaadin Label with empty string

查看:36
本文介绍了如何使用空字符串设置 Vaadin 标签的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档 如果您有一个空标签(带有空字符串的标签)宽度将折叠为 0.话虽如此,文档还说:如果您想要一个具有可调整宽度或高度的间隙,如果您为其指定高度或宽度,则可以使用空标签" 但是,当我这样做时,宽度仍然会折叠为 0.我需要宽度来保持它的大小,因为我为背景使用了不同的颜色.

According to the documentation if you have an empty Label (a Label with an empty string) the width will collapse to 0. That being said the documentation also says: "If you want a gap that has adjustable width or height, you can use an empty label if you specify a height or width for it" However when I do this the width still collapses to 0. I need the width to keep it's size because I use a different color for the background.

推荐答案

对我来说,向 whatEverIsTheStyleName.scss 添加样式以指定宽度工作正常:

For me adding style to whatEverIsTheStyleName.scss that specifies width works fine:

.emptyLabel {
    width: 500px;
}

那么简单:

emptyLabel.addStyleName("emptyLabel");

在类似 emptyLabel.setWidth(500, Unit.PIXELS); 的代码中设置它似乎不起作用.

Setting it in a code like emptyLabel.setWidth(500, Unit.PIXELS); seems not to work.

这篇关于如何使用空字符串设置 Vaadin 标签的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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