2013-06-18 237 views
0

我想弄清楚如何有兩個td標籤的表的一行留在另一行的頂部只有一個td標籤並完全對齊。我已經在最下面一行嘗試過colspan =「2」,但這不起作用。HTML表格元素對齊

這是我到目前爲止有:

<table cellpadding="0" cellspacing="0" border="0" width="800"><!--wrapper--> 
    <table border="1"> 
     <tr> 
      <td style="width: 50px"><img src="images/img1.jpg" /> 
      </td> 
      <td><img src="images/img2.jpg" /> 
      </td> 
      </tr> 
      <tr colspan="2"> 
      <td><img src="images/img3.jpg" /> 
      </td> 
      </tr> 
     </table> 
    </table> 

回答

5

變化

<tr colspan="2"> 
    <td><img src="images/img3.jpg" /> 
</td> 

<tr> 
    <td colspan="2"><img src="images/img3.jpg" /> 
</td> 

colspan應該在td

0

colspan屬於在<td>不是<tr>

<table cellpadding="0" cellspacing="0" border="0" width="800"> 
    <!--wrapper--> 
    <table border="1"> 
     <tr> 
      <td style="width: 50px"> 
       <img src="images/img1.jpg" /> 
      </td> 
      <td> 
       <img src="images/img2.jpg" /> 
      </td> 
     </tr> 
     <tr> 
      <td colspan="2"> 
       <img src="images/img3.jpg" /> 
      </td> 
     </tr> 
    </table> 
</table> 

jsFiddle example