无法将单词对齐到左侧

时间:2013-05-20 07:57:04

标签: html asp.net html-table text-align

我正在尝试创建一个包含2个表数据和2个表头的表。在研究了html代码之后,我意识到将单词向左移动的方法是Text-Align="Left",如下所示。不幸的是,它没有用。我没有使用任何CSS,只是简单的HTML代码。

这是我的代码:

<table style="width: 100%;">
    <tr>
        <th style="width: 189px; height: 23px;">Full Name:</th>
        <td style="width: 1910px; height: 23px;">
            <asp:Label ID="lblFullName" runat="server" Text="" Text-Align="Left"></asp:Label>
        </td>
        <th style="width: 21px; height: 23px;">Contact:</th>
        <td style="width: 684px; height: 23px">
            <asp:Label ID="lblContact" runat="server" Text=""></asp:Label>
        </td>
    </tr>
</table>

2 个答案:

答案 0 :(得分:1)

<asp:Label />会生成一个<span> HTML标记,该标记为inline,并且text-align未定义,否则设置text-align td 1}}:

<td style="width: 1910px; height: 23px; text-align: center;">
    <asp:Label ID="lblFullName" runat="server" Text=""></asp:Label>
</td>

或者将<asp:Label />作为block元素:

<asp:Label ID="lblFullName" runat="server" Text=""
    style="display: block; text-align: center;"
></asp:Label>

答案 1 :(得分:0)

试试这个......

<table style="width: 100%;">
    <tr>
        <td style="width: 189px; height: 23px;">Full Name:</td>
        <td style="width: 1910px; height: 23px;">
            <asp:Label ID="lblFullName" runat="server" Text="" Text-Align="Left"></asp:Label>
        </td>
    </tr>
    <tr>
        <td style="width: 21px; height: 23px;">Contact:</td>
        <td style="width: 684px; height: 23px">
            <asp:Label ID="lblContact" runat="server" Text=""></asp:Label>
        </td>
</tr>
</table>