Amateur with both CSS and vaadin here, trying to implement a responsive UI in Vaadin, but having issues with setting widths of UI objects; everything seems to break responsive CSS. Heres an example of what I’m describing:
[code]
CssLayout filterTypeLOptimiseBLayout = new CssLayout();
filterTypeLOptimiseBLayout.setResponsive(true);
filterTypeLOptimiseBLayout.addStyleName(“flexwrap”);
filterTypeLOptimiseBLayout.setSizeFull();
Label filtTypeLabel = new Label("Filter Type Filler");
filtTypeLabel.addStyleName("filtTypeLabel");
filtTypeLabel.setSizeFull();
filtTypeLabel.setResponsive(true);
filterTypeLOptimiseBLayout.addComponent(filtTypeLabel);
[/code]And the corresponding responsive CSS block applied to filtTypeLabel:
[code]
/* ---- Filter Type Filler Label ------*/
//Common to all sizes
.filtTypeLabel {
padding: 5px;
}
//Mobile
.filtTypeLabel[width-range~=“0-300px”]
{
font-size: 12pt; margin: 5px;
}
//Small Browser
.filtTypeLabel[width-range~=“301px-600px”]
{
font-size: 14pt; margin: 10px;
}
//Big Browser
.filtTypeLabel[width-range~=“601px-”]
{
font-size: 16pt; margin: 20px;
}
[/code]With the previous code, I achieve scaling of the button font and margin as expected, but I’d like control over the width of the label as well. Using filtTypeLabel.setSizeFull(); causes anything on the same line as the label to wrap around to the next line as the label occupies all space horizontally. Calling filtTypeLabel.setWidthUndefined(); instead breaks the responsive scaling, and filtTypeLabel.setWidth(“5%”); breaks it too. Setting max-width and min-width in the CSS also breaks it.
Is there any way to apply a set width to a Responsive CSS enabled object?