无法将单词对齐到左侧

问题描述 投票:1回答:2

我正在尝试创建一个包含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>
html asp.net html-table text-align
2个回答
1
投票

<asp:Label />将生成一个<span> HTML标记,这是inline,而text-align到它是未定义的,否则,设置text-aligntd

<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>

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>
© www.soinside.com 2019 - 2024. All rights reserved.