asp.net - 如何在 ASP.NET RadioButtonList 中的项目之间添加空格

我有一个 ASP.NET RadioButtonList,它使用 RepeatDirection="Horizo​​ntal" 将四个项目显示在一行上。我正在使用 RepeatLayout="Flow" 来避免表格的标记。但是,这会导致列表中的项目彼此相邻放置,这看起来不太好。

所以,我尝试了表格布局以利用 CellSpacing 和/或 CellPadding 属性。不幸的是,这些属性会影响表格中的垂直和水平间距/填充,所以当我得到水平间距时,我也得到了不需要的垂直间距。

在这一点上,我明白了:

<asp:RadioButtonList ID="rblMyRadioButtonList" runat="server" 
    RepeatDirection="Horizontal"
    RepeatLayout="Flow" >
    <asp:ListItem Selected="false" Text="Item One&nbsp;&nbsp;&nbsp;&nbsp;" Value="Item_1" />
    <asp:ListItem Selected="false" Text="Item Two&nbsp;&nbsp;&nbsp;&nbsp;" Value="Item_2" />
    <asp:ListItem Selected="false" Text="Item Three&nbsp;&nbsp;&nbsp;&nbsp;" Value="Item_3" />
    <asp:ListItem Selected="false" Text="Item Four&nbsp;&nbsp;&nbsp;&nbsp;" Value="Item_4" />
</asp:RadioButtonList>

...这对我大喊“你做得不对!”

实现此目的的正确方法是什么?

最佳答案

我知道这是一个老问题,但我是这样做的:

<asp:RadioButtonList runat="server" ID="myrbl" RepeatDirection="Horizontal" CssClass="rbl"> 

将此用作您的类(class):

.rbl input[type="radio"]
{
   margin-left: 10px;
   margin-right: 1px;
}

https://stackoverflow.com/questions/1822122/

相关文章:

c - intptr_t 和 uintptr_t 的字符串格式

coding-style - 线宽格式标准

Java - 将双值格式化为美元金额

javascript - 如何设置 VSCode 以将花括号放在新行上?

java - 使用 Java 将电话号码转换为国际格式 (E.164) 的最佳方法是什么?

html - 在 Visual Studio Code 中格式化 html 代码,使属性位于不同的行

c# - 如何格式化 Visual Studio 2012 中的所有文件?

c++ - 如何使用具有类似 printf 格式的 C++ std::ostream?

android - 点后 2 位 float

java - 日期和时间格式取决于区域设置