改变td的位置

时间:2015-08-20 13:24:07

标签: html css

我正在寻找一种方法来改变一个tr中两个td的位置。 所以开关位置。左边应该在右边,反之亦然。

<table>
    <tr>
        <td>left cell, but i should be on the right side</td>
        <td>right cell, and i want to be on the left side</td>
    </tr>
</table>

我试图左右浮动它们。

2 个答案:

答案 0 :(得分:1)

尝试这种方式:

* {margin: 0; padding: 0; list-style: none;}
table {width: 100%;}
tr:first-child {display: block; overflow: hidden; width: 100%;}
td {float: right; width: 50%;}
<table>
  <tr>
    <td>left cell, but i should be on the right side</td>
    <td>right cell, and i want to be on the left side</td>
  </tr>
</table>

答案 1 :(得分:0)

这应该有效。只需使用样式属性

<table>
    <tr>
        <td style="float:right; display:block;">left cell, but i should be on the right side</td>
        <td style="float:left; display:block;">right cell, and i want to be on the left side</td>
    </tr>
</table>
相关问题