Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在RadioButtonList asp.net控件的列表项之间添加空格?_C#_Css_Asp.net_Radiobuttonlist - Fatal编程技术网

C# 如何在RadioButtonList asp.net控件的列表项之间添加空格?

C# 如何在RadioButtonList asp.net控件的列表项之间添加空格?,c#,css,asp.net,radiobuttonlist,C#,Css,Asp.net,Radiobuttonlist,我花了一些时间在谷歌上搜索这个问题,尝试了一些事情,但似乎找不到解决这个问题的办法。我有一个RadioButtonList控件,看起来像: <asp:RadioButtonList ID="rblCheck" runat="server" RepeatDirection="horizontal"> <asp:ListItem Value="red">Red</asp:ListItem> <asp:ListItem Value="green">Gre

我花了一些时间在谷歌上搜索这个问题,尝试了一些事情,但似乎找不到解决这个问题的办法。我有一个RadioButtonList控件,看起来像:

<asp:RadioButtonList ID="rblCheck" runat="server" RepeatDirection="horizontal">
<asp:ListItem Value="red">Red</asp:ListItem>
<asp:ListItem Value="green">Green</asp:ListItem>
</asp:RadioButtonList>

红色
绿色

现在,当我在浏览器中查看它时,两个按钮非常接近。我有没有办法把它们隔开?我尝试了左边空白的css,但没有排序。任何建议都会很棒。谢谢

您是如何将CSS分配给该列表的?我询问的原因是,如果您试图通过引用ID“rblCheck”将CSS分配给列表,但该ID无效(.NET将更改ID并在值中附加一些数字)


尝试内联添加CSS或为列表指定一个类来分配CSS。

只需为其添加一些CSS即可:

input[type="radio"] {
 margin: 10px 10px;
}

你可以用很多方法来做。例如,您可以设置
RadioButtonList
控件的
CssClass
属性。看看下面

<asp:RadioButtonList ID="rblCheck" runat="server" RepeatDirection="horizontal" CssClass="spaced">
<asp:ListItem Value="red">Red</asp:ListItem>
<asp:ListItem Value="green">Green</asp:ListItem>
</asp:RadioButtonList>
或者,如果希望为列表项使用不同的间距,可以通过以下方式为每个
列表项指定
style
属性来实现

<asp:RadioButtonList ID="rblCheck" runat="server" RepeatDirection="horizontal">
<asp:ListItem Value="red" style="margin-right:20px">Red</asp:ListItem>
<asp:ListItem Value="green" style="margin-right:30px">Green</asp:ListItem>
</asp:RadioButtonList>

红色
绿色

只需添加一些CSS即可

input[type=radio] {
    margin-left: 8px;
}

我们需要看到CSS附加到输出HTMLI,就像第二种方法一样。更灵活。非常感谢。
input[type=radio] {
    margin-left: 8px;
}