2013-05-20 59 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