在Chrome中相对位置绝对浮动位置

时间:2016-04-27 20:15:21

标签: css

我有一个带有两个单元格的表格,右边单元格内有一个跨度。我希望跨度位于行的左端,所以我使用了这些样式:

span {
    position: absolute;
    left: 0;
}
tr {
    position: relative;
}

在Firefox中它运行良好,如下所示:

enter image description here

但是,Chrome会忽略位置:relative和span浮动在表外:

enter image description here

为什么会发生这种情况,我该如何解决?

这是jsfiddle:https://jsfiddle.net/9wa2sruu/

提前非常感谢你。 :)

1 个答案:

答案 0 :(得分:0)

你不能这样做吗?

tr, td {
  position: relative;
}

和html:

<tr>
  <td><span></span></td>
  <td></td>
</tr>

https://jsfiddle.net/9wa2sruu/9/