【发布时间】:2019-07-15 20:00:11
【问题描述】:
Flex wrap 在 IE 11 中的表的 tbody 中不起作用。我尝试了其他堆栈溢出帖子的不同建议,但没有一个有用。
如果您在 chrome/firefox/edge 中打开此 URL,您可以看到 flex wrap 工作正常,但在 IE 11 左右它不会 https://liveweave.com/j2yzx0
我也尝试使用this 作为参考,但没有多大用处。
* {
box-sizing: border-box;
}
table {
table-layout: fixed;
width: 100%;
border: 1px solid black;
}
tr {
border: 1px solid blue;
display: flex;
flex-wrap: wrap;
margin: 10px 0px;
}
th,
td {
border: 1px solid red;
text-align: center;
flex-basis: 26%;
}
<table>
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
<th>Col 3</th>
<th>Col 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>R1C1</td>
<td>R1C2</td>
<td>R1C3</td>
<td>R1C4</td>
</tr>
<tr>
<td>R2C1</td>
<td>R2C2</td>
<td>R2C3</td>
<td>R2C4</td>
</tr>
</tbody>
</table>
我什至尝试添加显示块、-ms- 前缀等但无济于事 链接在这里:https://liveweave.com/Liylfz
* {
box-sizing: border-box;
}
table,
tbody,
thead,
td,
th {
display: block;
}
table {
border: 1px solid black;
width: 100%;
}
thead,
tbody {
display: block;
}
tr {
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;
}
th,
td {
border: 1px solid red;
text-align: center;
padding: 5px;
background-color: #eee;
width: 50%;
flex-basis: 50%;
}
<table>
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
<th>Col 3</th>
<th>Col 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>R1C1</td>
<td>R1C2</td>
<td>R1C3</td>
<td>R1C4</td>
</tr>
<tr>
<td>R2C1</td>
<td>R2C2</td>
<td>R2C3</td>
<td>R2C4</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
使用 float: left 似乎有帮助,但由于使用 order 设置 flex 顺序不起作用,因此似乎没有任何 flex 属性起作用。
标签: html css internet-explorer flexbox