我有一行包含多个span元素的文本。例如:
<div class="line">
<span class="username">mario_sunny: </span><span class="message">Hello would you like to buy a <span class="item">Match</span>?</span>
</div>
问题是当我尝试使用GWT的InlineLabel或InlineHTML在Java中创建它时,它会修剪范围内的前导/尾随空格,如下所示:
如何防止这种情况?
这是我的代码:
HorizontalPanel lineLabel = new HorizontalPanel();
InlineHTML usernameLabel = new InlineHTML();
InlineLabel messageLabel = new InlineLabel();
lineLabel.setStyleName("chat-line");
usernameLabel.setStyleName("chat-username");
usernameLabel.setText("mario_sunny: ");
messageLabel.setText("Hello would you like to buy a Match?");
lineLabel.add(usernameLabel);
lineLabel.add(messageLabel);