How do I remove the margin automatically generated by vaddin


setTheme("test");
final Window mainWindow = new Window("Myproject Application");
setMainWindow(mainWindow);
mainWindow.setSizeUndefined();
VerticalLayout test = new VerticalLayout();
test.addStyleName("simp");
test.addComponent(new Label("123"));
mainWindow.addComponent(test);

@import "../reindeer/styles.css";

.test {
	border: 1px solid black;
}

1 How do I remove the margin or set margin to 0 ?
2 Is there any way to display VerticalLayout in the middle-center of the window ?
3 The right side of border is missing, how to solve ?
12106.png
12107.png

1 Remove the margin from a verticallayout :


.v-verticallayout-margin {
    padding : 0;
}

Windows already contains a VerticalLayout (with margins) so when you do :

mainWindow.addComponent(test);

You are adding a VerticalLayout in a VerticalLayout.

You can use mainWindow.setContent(test); to replace the default VerticalLayout by the one you created.

Or if you want to keep the default layout but wants to remove the margins do :


((VerticalLayout)mainWindow.getContent()).setMargins(false);
mainWindow.addComponent(test);
mainWindow.setContent(test);

Thanks
It solved the first problem.

Due to size calculations, you are not able to use CSS border, spacing or marging in core Vaadin layouts. To add border, wrap your layout inside a Panel, use CssLayout or use layout add-ons from Vaadin Directory.

Thank you, I will try to test