我正在尝试使用 cssclass 添加空格。我使用以下代码进行了编码,但没有得到任何额外的空格。
为此编写代码的正确方法是什么?
.checkboxlistformat {
margin-left:30px;
}
<div align="center" runat="server" id="checkboxlistdiv">
<asp:CheckBoxList ID="checkboxlisttest" CssClass="checkboxlistformat" runat="server" RepeatLayout="table" RepeatColumns="4" RepeatDirection="vertical" OnSelectedIndexChanged="checkboxlist_SIC_SelectedIndexChanged"></asp:CheckBoxList>
</div>
最佳答案
假设您的 ASP 生成相应的 <label>
对于文本。您可以使用祖先后代选择器将文本定位为 .checkboxlistformat label
:
.checkboxlistformat label {
margin-left: 30px;
}
<input id="checkboxlisttest" type="checkbox" class="checkboxlistformat">
<label for="checkboxlisttest">Checkbox</label>
或者,您始终可以简单地将边距放在复选框的右侧:
.checkboxlistformat {
margin-right: 30px;
}
<input id="checkboxlisttest" type="checkbox" class="checkboxlistformat">
<label for="checkboxlisttest">Checkbox</label>
希望对您有所帮助! :)
关于html - 在复选框列表文本和复选框之间添加空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48332566/