顶部和左侧的vaadin按钮边距

顶部和左侧的vaadin按钮边距,vaadin,Vaadin,我无法向按钮添加样式 在我的scss文件中,有与 .button-margin { margin-top: 15%; margin-left: 35%; } .v-button-caption { font-size: 15pt; } 当v-button-caption工作时——当我通过myButton.addStyleNamebutton-margin对按钮应用样式时;-它不会更改按钮的位置 有什么问题吗 我的整个按钮代码 public VerticalLayout

我无法向按钮添加样式

在我的scss文件中,有与

.button-margin {
    margin-top: 15%;
    margin-left: 35%;
}

.v-button-caption {
    font-size: 15pt;
}
当v-button-caption工作时——当我通过myButton.addStyleNamebutton-margin对按钮应用样式时;-它不会更改按钮的位置

有什么问题吗

我的整个按钮代码

public VerticalLayout redirectButton() {
        VerticalLayout buttonLayout = new VerticalLayout();
        buttonLayout.setMargin(true);
        Button b = new Button("Redirect to another application");
        b.setHeight("50px");
        b.setWidth("400px");
        b.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                NotificationsAdminUi.getCurrent().getPage().getJavaScript()
                    .execute("window.location.href='"
                         + "http://xxxx:8080/xxxx'");
            }

        });
        buttonLayout.addComponent(b);
        return buttonLayout;
    }

你可能是说px而不是%?愚蠢的问题,但是你重新编译了主题吗?此外,在Vaadin布局中使用css边距时要小心,它可能会干扰SetSizevel等。这其实并不重要,不管是%还是px。这两种情况对我都不起作用。你说它会干扰你是什么意思?我只想把我的按钮稍微向下和向左移动。瓦丁为你计算宽度/高度。若您这样更改边距,他可能无法正确计算布局的整体大小,并且您会得到不必要的溢出。更好的方法是使用setMargintrue来获得组件周围的一致边距。你说得对,大约%,这并不典型。你的代码在我看来绝对不错。您是否有很多其他样式,例如在父组件中?我建议使用一些客户端调试器查看生成的DOM树,比如Firefox的Firebug插件,或者Chrome和IE的开发工具F12。