0

I have an asp.net table with 1 row and 2 cells in each row. I am trying to get the right cell to display near the right most edge of the cell with no success.

<asp:Table runat="server" ID="tblMyTable" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" Font-Names="Arial" BackColor="White" Width="190" ClientIDMode="Static">
        <asp:TableRow Font-Names="Arial Black">
            <asp:TableCell HorizontalAlign="Left" CssClass="HeaderPadding">
                <asp:Label runat="server" ID="lblID" Text="361299"></asp:Label>
            </asp:TableCell>
            <asp:TableCell HorizontalAlign="Right">
                <asp:Label runat="server" ID="lblPercentage" Text="79%"></asp:Label>
            </asp:TableCell>
        </asp:TableRow>
</Asp:Table>

<style>
.HeaderPadding 
    {
        padding:0px 0px 10px 0px;
    }
</style>

I want to display like this:

enter image description here

How can I align the percentage label correctly?

instead it looks like this for some cells but looks ok in others.

enter image description here

4

2 回答 2

3

Try this:

<table>
    <tr>
        <td class="HeaderPadding">
            <asp:Label runat="server" ID="lblID" Text="361299"></asp:Label>
        </td>
        <td style="text-align: right">
            <asp:Label runat="server" ID="lblPercentage" Text="79%"></asp:Label>
        </td>
    </tr>
</table>
于 2013-09-27T14:48:43.680 回答
0

你可以使用如下的css类

  <style type="text/css">
    .rightAlign { text-align:right; }
    </style>

在你的标签中

<asp:Label runat="server" ID="lblPercentage" Text="79%" CssClass="rightAlign"></asp:Label>
于 2013-09-27T14:52:50.940 回答