我怎么项目之间在ASP.NET单选按钮列表添加空间
我有一个ASP.NET单选按钮列表,使用显示四个项目的的 RepeatDirection =水平的以显示它们在一行。我使用的的 RepeatLayout =流的,以避免标记为表。但是,这会导致在列表中的项目的旁边放置到彼此,其中不好看。
I've got an ASP.NET RadioButtonList that displays four items using RepeatDirection="Horizontal" to display them on a single line. I'm using RepeatLayout="Flow" to avoid the markup for a table. However, this causes the items in the list to be placed right next to each other, which does not look good.
所以,我尝试了表格布局采取 CELLSPACING 的和/或的 CELLPADDING 的性能优势。不幸的是,这些性质影响到垂直和水平间距/填充的表内,因此,虽然我得到的水平间距,我也得到不希望的垂直间距
So, I tried the table layout to take advantage of the CellSpacing and/or CellPadding properties. Unfortunately, these properties affect both the vertical and horizontal spacing/padding within the table, so while I get the horizontal spacing, I also get undesired vertical spacing.
在这一点上,我到这一点:
At this point, I'm down to this:
<asp:RadioButtonList ID="rblMyRadioButtonList" runat="server"
RepeatDirection="Horizontal"
RepeatLayout="Flow" >
<asp:ListItem Selected="false" Text="Item One " Value="Item_1" />
<asp:ListItem Selected="false" Text="Item Two " Value="Item_2" />
<asp:ListItem Selected="false" Text="Item Three " Value="Item_3" />
<asp:ListItem Selected="false" Text="Item Four " Value="Item_4" />
</asp:RadioButtonList>
...这尖叫看着我你不这样做是正确的!
...which screams at me "You're not doing it right!"
什么是实现这一目标的正确方法?
What is the right way to accomplish this?
使用CSS的权利保证金添加到这些特定元素。一般来说,我会生成控件,然后运行它看到生成的HTML结构是什么样的,然后让CSS改变只是这些元素。
Use css to add a right margin to those particular elements. Generally I would build the control, then run it to see what the resulting html structure is like, then make the css alter just those elements.
preferably通过设置来实现这个目的。在的CssClass =myrblclass
属性添加到列表的声明。
Preferably you do this by setting the class. Add the CssClass="myrblclass"
attribute to your list declaration.
您还可以添加属性的项目编程,它会出来的另一面。
You can also add attributes to the items programmatically, which will come out the other side.
rblMyRadioButtonList.Items[x].Attributes.CssStyle.Add("margin-right:5px;")
这可能是对你更好,因为你可以添加属性为所有,但最后一个。
This may be better for you since you can add that attribute for all but the last one.