【发布时间】:2016-05-28 20:13:20
【问题描述】:
我正在寻找一种解决方案,如何让 Flex 属性在所有三种浏览器(IE、Firefox 和 Chrome)上的 table 组件上工作。
以下代码仅适用于 Chrome(即使添加了 -ms- 和 -webkit- 前缀):
table {
background-color: white;
}
.child {
padding: 5px;
margin: 5px;
background-color: #eee;
border: 3px solid;
}
.container {
padding: 2px;
background-color: yellow;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-align-items: stretch;
-ms-flex-align: stretch;
align-items: stretch;
}
.child.one {
color: green;
-webkit-order: 1;
-ms-flex-order: 1;
order: 1;
}
.child.two {
color: purple;
-webkit-order: 2;
-ms-flex-order: 2;
order: 2;
flex-shrink: 0;
}
.child.three {
color: red;
-webkit-order: 3;
-ms-flex-order: 3;
order: 3;
}
<table style="width:100%">
<tbody>
<tr class="container">
<td class="child one" align="left">
One
</td>
<td class="child two" align="center">
Two.
<br>Lorem ipsum
<br>dolor sit amet
<br>This is a bit longer line
</td>
<td class="child three" align="right">
Three
</td>
</tr>
</tbody>
</table>
请查看小提琴中的代码: http://jsfiddle.net/ax961ys1/
【问题讨论】:
-
@nick 我知道。但是当我在
div元素上使用它时,一切正常。所以我想,我在这张表上做错了。 -
@werasquez 以供将来参考,我已将您的整个代码移到 Stack Snippet 中,因为 Stack Overflow 要求完整代码位于问题本身而不是外部位置(例如 JS Fiddle)中以防链接失效。
标签: html css cross-browser flexbox