将两个表列相互对齐

时间:2016-06-24 19:16:03

标签: html css html-table

是否可以排列这两个表格,使单元格1a与单元格2a对齐?就像现在一样,左外侧列似乎垂直居中于右外侧列

进一步向下是源(html),然后是屏幕截图

<table>
  <tr> 
    <td>
      <table class="payment"> 
        <tr>
          <td> <input type="checkbox"></td>
          <td>info (1a)</td>
        </tr>
        <tr>
          <td></td>
          <td> descr ...</td>
        </tr>
      </table>
      <table class="payment"> 
        <tr>
          <td> <input type="checkbox"></td>
          <td>info (1b)</td>
        </tr>
        <tr>
          <td></td>
          <td> descr ...</td>
        </tr>
      </table>
      <table class="payment"> 
        <tr>
          <td> <input type="checkbox"></td>
          <td>info (1c)</td>
        </tr>
        <tr>
          <td></td>
          <td> descr ...</td>
        </tr>
      </table>
    </td>

    <!-- OUTER COLUMN 2 -->
    <td>
      <table class="payment">	
        <tr>
          <td> <input type="checkbox"></td>
          <td>info (2a)</td>
        </tr>
        <tr>
          <td></td>
          <td> decr ...</td>
        </tr>
      </table>
      <table class="payment">
        <tr>
          <td> <input type="checkbox"></td>
          <td>info (2b)</td>
        </tr>
        <tr>
          <td></td>
          <td> descr ...</td>
        </tr>
      </table>
      <table class="payment">
        <tr>
          <td> <input type="checkbox"></td>
          <td>info (2c)</td>
        </tr>
        <tr>
          <td></td>
          <td> descr ...</td>
        </tr>
      </table>
      <table class="payment">
        <tr>
          <td> <input type="checkbox"></td>
          <td>info (2d)</td>
        </tr>
        <tr>
          <td></td>
          <td> descr ...</td>
        </tr>
      </table>
    </td>
  </tr>
</table>

图像 enter image description here

1 个答案:

答案 0 :(得分:3)

直接html首先valign=top添加tr

<table>
    <tr valign=top> 
        <td>

        <table class="payment"> 
            <tr>
                <td> <input type="checkbox"></td>
                <td>info (1a)</td>
            </tr>
            <tr>

即使class="payment"样式中的某些内容影响定位