C# 使用ASP.Net将标签向右对齐
我在ASP.NET页面上有一个标签。现在看起来是这样的:C# 使用ASP.Net将标签向右对齐,c#,css,asp.net,.net,label,C#,Css,Asp.net,.net,Label,我在ASP.NET页面上有一个标签。现在看起来是这样的: <div style="text-align:right"> <asp:Label ID="myLabel" runat="server" Text="Label"></asp:Label> </div> 我希望它看起来像这样: <div style="text-align:right"> <asp:Label ID="myLabel" runat="s
<div style="text-align:right">
<asp:Label ID="myLabel" runat="server" Text="Label"></asp:Label>
</div>
我希望它看起来像这样:
<div style="text-align:right">
<asp:Label ID="myLabel" runat="server" Text="Label"></asp:Label>
</div>
我试过使用DIV标记,也试过在
标记中使用Style=“text align:right”,但两种方法都不起作用。有什么建议吗
编辑:根据第一条注释,这都在表标记内:
<asp:Panel ID="Panel2" runat="server" BackColor="#0f6fc6" Height="110px" Width="780px">
<table style="width:780px">
<tr>
<td style="width:90px">
<asp:Label ID="lblFunct" runat="server" Font-Bold="True" Text="Function" ForeColor="White"></asp:Label>
</td>
<td style="width:240px">
<asp:DropDownList ID="ddlFunction" runat="server" AutoPostBack="True" CssClass="textbox" Height="20px" OnSelectedIndexChanged="ddlFunction_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
</td>
<td style="width:120px">
<asp:Label ID="lblRole" runat="server" Font-Bold="True" Text="Role" ForeColor="White"></asp:Label>
</td>
<td style="width:240px">
<asp:DropDownList ID="ddlRole" runat="server" AutoPostBack="True" CssClass="textbox" Height="20px" OnSelectedIndexChanged="ddlRole_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblProd" runat="server" Font-Bold="True" Text="Prod Tasks" ForeColor="White"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlTask" runat="server" AutoPostBack="True" CssClass="textbox" Height="20px" OnSelectedIndexChanged="ddlTask_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
</td>
<td>
<asp:Label ID="lblOffprod" runat="server" Font-Bold="True" Text="Off Prod Tasks" ForeColor="White"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlOffprod" runat="server" AutoPostBack="True" CssClass="textbox" Height="20px" OnSelectedIndexChanged="ddlOffprod_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2">
<asp:RadioButtonList ID="rblPlatform" runat="server" EnableTheming="True" Font-Size="XX-Small" Height="10px" RepeatColumns="2" Visible="false" Width="270px" ForeColor="White" Font-Bold="True" TextAlign="Left">
<asp:ListItem Selected="True" Value="0">Facets </asp:ListItem>
<asp:ListItem Value="1">Non-Facets</asp:ListItem>
</asp:RadioButtonList>
</td>
<td colspan="2">
<asp:Label ID="lblAccountName" runat="server" Text="Label" ForeColor="White" Visible="true" Style="text-align: right"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
面
非面
尝试以下方法:
<div style="text-align:right">
<asp:Label ID="myLabel" runat="server" Text="Label"></asp:Label>
</div>
您可以将标签放在div中,然后在标签标签标签中放入
style=“float:left”
这与ASP.NET关系不大,而与HTML/CSS关系很大。这里实际的HTML是什么?当前应用于它的样式是什么?在代码隐藏中使用它,如下所示--createDiv2.Attributes.Add(“Style”,“float:right;”)--谢谢你的主意!干杯