jmizv
jmizv

Reputation: 1322

Adding two Labels but they have no space between them

I have added to my layout two labels:

Div container = new Div();
container.add(new Label(getTranslation(MessageConstants.SOME_DESCRIPTION)));
container.add(new Label(getTranslation(MessageConstants.MORE_DESCRIPTION_TEMPLATE, valueToAdd)));
add(container);

But this results in having no space between the labels. This looks bad, see image:

Screenshot

What is the best way to avoid this without combining both translation labels?

Upvotes: 0

Views: 305

Answers (2)

Tarek Oraby
Tarek Oraby

Reputation: 1219

There are several ways to add a space between the two labels. But one way is to add some right padding to the first component like so:

Div container = new Div();
Label firstLabel = new Label("first");
firstLabel .getStyle().set("padding-right", "10px");
container.add(firstLabel);
container.add(new Label("second"));

Upvotes: 3

gidravlic
gidravlic

Reputation: 114

and should not -> please see Browser Inspector (padding, margins)

Upvotes: 0

Related Questions