[英]Align a label to the right using ASP.Net
我在ASP.NET頁上有一個標簽。 現在,它看起來像這樣:
我希望它看起來像這樣:
我嘗試使用DIV標記,並且嘗試在<asp:Label>
標記中使用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"
。
<div>
<asp:label ID="myLabel" runat="server" style="float:right"></asp:Label>
</div>
編輯:
另外,為了完整起見,如Aimal Khan所述,您可以在后面的代碼中將其用作:
myLabel.Attributes.Add("Style", "float: right");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.