2013-09-28 24 views
0

我有一個主頁,其中它們是一個包含3行的表格。 第一行是header 2的body和foot 3的header。 標題行再次包含一個具有1行和3列的表。 第一列寬固定爲238像素,最後一列固定爲7%寬度。中間的col佔據了所有的左邊空間。將不同的表格行中的兩個元素對齊,以使它們的起始位置相同

第二行還包含3列,第1列= 20%,第3列= 20%,其餘列爲中間列。

問題: - 我必須以內部內容從相同水平位置開始的方式來對齊表格的中間列。

下面是HTML的具有所需樣式的示例

<html xmlns="http://www.w3.org/1999/xhtml"> 

.style1 { 寬度:100%; }

<div align="center"> 
    <table align="center" class="style1"> 
     <tr> 
      <td> 
       <div align="center"> 
        <table align="center" class="style1"> 
         <tr> 
          <td width="238px"> 
           Logo width = 238px</td> 
          <td align="center"> 
           <div style="background-color: #008000"> 
            start line should aling with the below start line</div> 
          </td> 
          <td width="7%"> 
           cart width =7%</td> 
         </tr> 
        </table> 
       </div> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <div align="center"> 
        <table align="center" class="style1"> 
         <tr> 
          <td width="20%"> 
           &nbsp;</td> 
          <td align="center"> 
           start line should aling with the top</td> 
          <td width="20%"> 
           &nbsp;</td> 
         </tr> 
        </table> 
       </div> 
      </td> 
     </tr> 
    </table> 
</div> 

我需要阿玲 '啓動線'(與的bgcolor =綠色和TD DIV),使他們從同一位置開始。

回答

0

第二張表中第一張<td>的寬度也應該是238px。

<td width="238px">&nbsp;</td> 

編輯:你有一個<風格>標籤定義樣式1?如果沒有,第二個<tbody>將減小寬度。

<style type="text/css">.style1 { width: 100%; } </style> 
0
<div align="center"> 
    <table align="center" class="style1"> 
     <tr> 
      <td> 
       <div align="center"> 
        <table align="center" class="style1"> 
         <tr> 
          <td width="238px"> 
           Logo width = 238px</td> 
          <td style="padding-left:50px; background-color: #008000"> 
            start line should aling with the below start line 
          </td> 
          <td width="7%"> 
           cart width =7%</td> 
         </tr> 
        </table> 
       </div> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <div align="center"> 
        <table align="center" class="style1"> 
         <tr> 
          <td width="238px"> 
           &nbsp;</td> 
          <td style="padding-left:50px;"> 
           start line should aling with the top</td> 
          <td width="20%"> 
           &nbsp;</td> 
         </tr> 
        </table> 
       </div> 
      </td> 
     </tr> 
    </table> 
</div> 

使用填充代替align="center"

+0

沒有填充沒有做它應該做的,實際上是寬度的百分比100%確定,我需要在所有分辨率> 600px的寬度相同的佈局 – Ratna

相關問題