Table cells right align inside row

前端 未结 5 1348
情话喂你
情话喂你 2021-01-21 02:24

I\'m trying to figure out how to move a cell to the left on HTML table. I want to use less cells in the last row and it\'s on the right by default.

I have this table for

相关标签:
5条回答
  • 2021-01-21 03:10

    I'm looking for a way with less as possible css.. preferred HTML only.

    You can try align attribute of td with colspan.

    <table>
    <tr>
      <th>one</th>
      <th>two</th>
      <th>three</th>
    </tr>
    <tr>
      <td>one</td>
      <td>two</td>
      <td>three</td>
    </tr>
    <tr>
      <td>this</td>
      <td colspan="2" align="right">right</td>
    </tr>
    </table>

    0 讨论(0)
  • 2021-01-21 03:12

    The td should span two columns by using the attribute colspan="2", and align the text to the right:

    .alignRight {
      text-align: right;
    }
    <table>
      <tr>
        <th>one</th>
        <th>two</th>
        <th>three</th>
      </tr>
      <tr>
        <td>one</td>
        <td>two</td>
        <td>three</td>
      </tr>
      <tr>
        <td>this</td>
        <td colspan="2" class="alignRight">right</td>
      </tr>
    </table>

    Another, html only, option is to use colspan="2" on the "this" cell:

    <table>
      <tr>
        <th>one</th>
        <th>two</th>
        <th>three</th>
      </tr>
      <tr>
        <td>one</td>
        <td>two</td>
        <td>three</td>
      </tr>
      <tr>
        <td colspan="2">this</td>
        <td>right</td>
      </tr>
    </table>

    0 讨论(0)
  • 2021-01-21 03:17

    <tr> <td colspan="2">this</td> <td align="right">right</td> </tr>

    colspan can be used in both cells. This will merge cell into 2.

    0 讨论(0)
  • 2021-01-21 03:23

    you can only add align="right" attribute

    <table>
      <tr>
        <th>one</th>
        <th>two</th>
        <th>three</th>
      </tr>
      <tr>
        <td>one</td>
        <td>two</td>
        <td>three</td>
      </tr>
      <tr>
        <td>this</td>
        <td colspan="2" align="right">right</td>
      </tr>
    </table>

    0 讨论(0)
  • 2021-01-21 03:25

    Or just insert an empty cell before <td>this</td>

    <table>
      <tr>
        <th>one</th>
        <th>two</th>
        <th>three</th>
      </tr>
      <tr>
        <td>one</td>
        <td>two</td>
        <td>three</td>
      </tr>
      <tr>
        <td></td>
        <td>this</td>
        <td>right</td>
      </tr>
    </table>

    0 讨论(0)
提交回复
热议问题