【问题标题】:Unable to align word to the left无法将单词左对齐
【发布时间】:2013-05-14 17:51:27
【问题描述】:
我正在尝试创建一个包含 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
【解决方案1】:
试试这个...
<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>
【解决方案2】:
<asp:Label />会生成一个<span> HTML标签,即inline,而text-align是未定义的,否则设置td的text-align:
<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>