2013-05-20 44 views
1

我正在尝试创建包含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> 

回答

1

<asp:Label />将产生<span> HTML标签,这是inline,并text-align它是不确定的,否则,设置tdtext-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> 
+0

谢谢!有用。 –

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

http://jsfiddle.net/h4DJK/ – Sanath