CSS 单选按钮列表布局 ASP .Net

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6849794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:07:14  来源:igfitidea点击:

Radio Button List Layout ASP .Net

asp.netcssradiobuttonlist

提问by Hiral Desai

I'm having trouble achieving desired layout for radiobuttonlist. I want the output to look like the image below.

我无法实现单选按钮列表所需的布局。我希望输出看起来像下图。

Here is a link to what I'm trying to achieve:

这是我要实现的目标的链接:

http://skitch.com/hiraldesai/fcfn9/radio-button-layout

http://skitch.com/hiraldesai/fcfn9/radio-button-layout

Here is my code trying to achieve the above, but I am not able to get the text above the radio button programmatically. Is it a CSS thing? I have tried many different combinations of RepeatLayout, RepeatDirection, RepeatColumns, TextAlign, etc.

这是我试图实现上述目标的代码,但我无法以编程方式获取单选按钮上方的文本。它是一个 CSS 的东西吗?我尝试了许多不同的 RepeatLayout、RepeatDirection、RepeatColumns、TextAlign 等组合。

AnswerRadioButtons.RepeatLayout = RepeatLayout.Table
AnswerRadioButtons.RepeatDirection = RepeatDirection.Horizontal                            

Thanks for advising.

谢谢指教。

回答by abney317

I was able to do it with this test.

我能够通过这个测试做到这一点。

<asp:RadioButtonList ID="rbl" runat="server" RepeatDirection="Horizontal" 
        RepeatLayout="Table" CssClass="RBL" TextAlign="Left">
    <asp:ListItem Text="radio button 1" />
    <asp:ListItem Text="radio button 1" />
    <asp:ListItem Text="radio button 1" />
</asp:RadioButtonList>

With this css

有了这个 css

.RBL label
{
    display: block;
}

.RBL td
{
    text-align: center;
    width: 20px;
}