我对IE11有疑问:我希望tabbar
占用所需的高度,一行或多行。
该表应占用剩余高度并显示水平和垂直滚动条。
当宽度太窄而按钮被包裹到第二行,第三行......行时会出现问题。
还有另一种方法可以在IE11中使用吗?
#container {
display: flex;
display: -ms-flexbox;
flex-direction: column;
height: 100vh;
}
.tabbar {
display: block;
text-align: left;
list-style-type: none;
}
.tabbar li {
display: inline-block;
background-color:#ddd;
font-size:30px;
padding:10px 20px;
margin:5px;
}
table {
display: block;
flex: 1 1 auto;
font-size: 16px;
min-height: 100px;
overflow: scroll;
background-color:orange;
}
<div id="container">
<ul class="tabbar">
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
<li>Six</li>
<li>Seven</li>
<li>Eight</li>
<li>Nine</li>
<li>Ten</li>
<li>Eleven</li>
<li>Twelve</li>
</ul>
<table>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
<tr>
<td>row</td>
</tr>
</table>
</div>
答案 0 :(得分:9)
IE11允许ul.tabbar
弹性项目缩小到其内容大小(列表项)之下。
列表项溢出ul
并与下面的表格重叠。
要在IE11中查看此效果,请向overflow: hidden
添加边框或.tabbar
。
其他浏览器不会让容器缩小到其内容大小以下。
要解决此问题,请将其添加到您的代码中:
.tabbar { flex-shrink: 0; }
#container {
display: flex;
display: -ms-flexbox;
flex-direction: column;
height: 100vh;
}
.tabbar {
display: block;
text-align: left;
list-style-type: none;
flex-shrink: 0;
border: 1px dashed red;
}
.tabbar li {
display: inline-block;
background-color: #ddd;
font-size: 30px;
padding: 10px 20px;
margin: 5px;
}
table {
display: block;
flex: 1 1 auto;
font-size: 16px;
min-height: 100px;
overflow: scroll;
background-color: orange;
}
<div id="container">
<ul class="tabbar">
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
<li>Six</li>
<li>Seven</li>
<li>Eight</li>
<li>Nine</li>
<li>Ten</li>
<li>Eleven</li>
<li>Twelve</li>
</ul>
<table>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
<tr><td>row</td></tr>
</table>
</div>