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

标签 java wicket wicket-1.5

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

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

我的代码如下:

HTML代码

<div wicket:id="leasedLineChildChkLeft" style="width: 50%; float: right;"></div>

Java代码

 final CheckBoxMultipleChoice<Integer> leasedLineChildDivLeft = new CheckBoxMultipleChoice<Integer>("leasedLineChildChkLeft", new Model(llSpeedSelectLeft), llSpeedListLeft);

在前端生成的结果动态 html

    <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 元素而不是复选框

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

最佳答案

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

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

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

关于java - Wicket::如何在 CheckBoxMultipleChoice 的复选框中添加样式边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23566909/

相关文章:

java - 如何设置 Web 应用程序以在 JAVA 中使用 ADFS/SAML/WS-*?

java - Wicket - 异常处理后正确清理页面组件

Java反射运行时性能

java - 添加数组中的数字序列并打印第 n 个数字

java - 分析/过滤所有变量而不声明每个变量?

session - WebSession ClassCastException

java - 如何在 Wicket 中创建可靠的调色板

java - 如何使用Eclipse在GUI中添加图像?此代码不显示图像

java - 如何创建 Wicket MarkupContainer 以在 JUnit 测试实用程序类中使用?

html - WicketTester 如何获取组件的 html 输出?