您需要将项目分组并排div
,或者添加额外的间距以对齐第二个项目。
浮动div:
<div style="float: left;">
<span>Sex:</label>
</div>
<div style="float: left;">
<asp:RadioButton ID="male" runat="server" GroupName="gender" Text="Male"/>
<br/>
<asp:RadioButton ID="female" runat="server" GroupName="gender" Text="Female"/>
</div>
<div style="clear: both"></div>
或填充:
<style>
.radioButtonPadding {
display: inline-block;
width: 45px;
}
</style>
<span class="radioButtonPadding">Sex:</label>
<asp:RadioButton ID="male" runat="server" GroupName="gender" Text="Male"/>
<br/>
<span class="radioButtonPadding"> </label>
<asp:RadioButton ID="female" runat="server" GroupName="gender" Text="Female"/>
您也可以将其作为RadioButtonList
<style>
.genderLabel {
float: left;
display: block;
}
.genderList {
float: left;
}
.clear {
clear: both;
}
</style>
<asp:Label id="genderLabel" runat="server" CssClass="genderLabel"
Text="Sex:" AssociatedControlID="genderList"/>
<asp:RadioButtonList id="genderList" runat="server" CssClass="genderList">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
<div class="clear"></div>