Java Wicket::如何在CheckBoxMultipleChoice的复选框中添加样式边距

Java Wicket::如何在CheckBoxMultipleChoice的复选框中添加样式边距,java,wicket,wicket-1.5,Java,Wicket,Wicket 1.5,我将列表传递给CheckBoxMultipleChoice,并使用ApacheWicket在前端生成复选框 我想在所有复选框之间添加边距 我的代码如下: HTML代码 <div wicket:id="leasedLineChildChkLeft" style="width: 50%; float: right;"></div> 但其结果是将类添加到div元素而不是复选框中 如何在复选框之间添加边距?您可以尝试以下方法: leasedLineChildDivLeft.ad

我将列表传递给CheckBoxMultipleChoice,并使用ApacheWicket在前端生成复选框

我想在所有复选框之间添加边距

我的代码如下:

HTML代码

<div wicket:id="leasedLineChildChkLeft" style="width: 50%; float: right;"></div>
但其结果是将类添加到div元素而不是复选框中


如何在复选框之间添加边距?

您可以尝试以下方法:

leasedLineChildDivLeft.add(新的SimpleAttributeModifier(“样式”,“边距:0自动;”)

而不是


添加(新的SimpleAttributeModifier(“class”,“metaCommentListStyle”)

使用CSS子选择器设置输入样式:

div.metaCommentListStyle input {
     margin-left: 4px;
}

如果您需要对标记进行更多控制,请使用CheckGroup/Check。

您使用的Wicket版本是什么?这与Swing有什么关系?我已经尝试过了;这将为div而不是checkbox添加样式这是一个完美的解决方案。我使用了与#id输入{margin}相同的方法
    <div class="metaCommentListStyle" style="width: 50%; float: left;" wicket:id="leasedLineChildChkLeft"><input type="checkbox" id="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_0" value="0" name="commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft"><label for="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_0">1</label><br>
<input type="checkbox" id="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_1" value="1" name="commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft"><label for="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_1">2</label><br>
<input type="checkbox" id="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_2" value="2" name="commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft"><label for="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_2">3</label><br>
<input type="checkbox" id="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_3" value="3" name="commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft"><label for="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_3">4</label><br>
<input type="checkbox" id="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_4" value="4" name="commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft"><label for="leasedLineChildChkLeft67-commentChoiceDiv:leasedLineDiv:leasedLineChildDiv:0:leasedLineChildChkLeft_4">5</label><br>
</div>
leasedLineChildDivLeft.add(new SimpleAttributeModifier("class", "metaCommentListStyle"));
div.metaCommentListStyle input {
     margin-left: 4px;
}