RadioButton和列表,文本不符合无线电

时间:2016-06-16 13:22:55

标签: asp.net radio-button radiobuttonlist

你好,我有这样的事情

        <asp:RadioButtonList ID="RadioButtonList1"
            RepeatColumns="2"
            RepeatDirection="Vertical"
            RepeatLayout="Table"
            TextAlign="Left"
            runat="server">
             <asp:ListItem Text="Nacional" Value="nacional" />
             <asp:ListItem Text="Departamental" Value="departamental" />
             <asp:ListItem Text="Politica" Value="politica" />
             <asp:ListItem Text="Sociales" Value="social" />
             <asp:ListItem Text="Policial" Value="policial" />
             <asp:ListItem Text="Deportes" Value="deporte" />
        </asp:RadioButtonList>

enter image description here

正如你所看到的文字略高,看起来很奇怪,为什么会这样?

这里我添加了html

    <div class="formline">
        <table id="MainContent_RadioButtonList1">
<tr>
    <td><label for="MainContent_RadioButtonList1_0">Nacional</label><input id="MainContent_RadioButtonList1_0" type="radio" name="ctl00$MainContent$RadioButtonList1" value="nacional" /></td><td><label for="MainContent_RadioButtonList1_3">Sociales</label><input id="MainContent_RadioButtonList1_3" type="radio" name="ctl00$MainContent$RadioButtonList1" value="social" /></td>
</tr><tr>
    <td><label for="MainContent_RadioButtonList1_1">Departamental</label><input id="MainContent_RadioButtonList1_1" type="radio" name="ctl00$MainContent$RadioButtonList1" value="departamental" /></td><td><label for="MainContent_RadioButtonList1_4">Policial</label><input id="MainContent_RadioButtonList1_4" type="radio" name="ctl00$MainContent$RadioButtonList1" value="policial" /></td>
</tr><tr>
    <td><label for="MainContent_RadioButtonList1_2">Politica</label><input id="MainContent_RadioButtonList1_2" type="radio" name="ctl00$MainContent$RadioButtonList1" value="politica" /></td><td><label for="MainContent_RadioButtonList1_5">Deportes</label><input id="MainContent_RadioButtonList1_5" type="radio" name="ctl00$MainContent$RadioButtonList1" value="deporte" /></td>
</tr>

        

1 个答案:

答案 0 :(得分:1)

RadioButtonList控件的dafault行为是显示文本和单选按钮相互之间的相互关系,如果它们不是adjecent,则意味着您的Web应用程序中某处有一个CSS规则,它改变了默认行为

您可以在Google Chrome中使用F12来检查HTML和CSS,并尝试找出导致问题的样式规则:

Using developer tools in Google Chrome

您还可以尝试将下面的样式规则添加到您拥有RadioButtonList控件的页面,只需确保在所有其他CSS引用之后添加

<style type="text/css">
    table#RadioButtonList1 td
    {
        vertical-align:top;
        height:100px;
    }
</style>