【发布时间】:2016-11-22 17:47:47
【问题描述】:
我想要一个固定高度的标题,全高/全宽的表格,然后是下面的一些 div,最好使用 flexbox。
如何在没有滚动条的情况下做到这一点,以便所有内容都占据整个页面?
这是我的尝试:https://jsfiddle.net/1nyv4pqk/2/
html, body {
height: 100%;
width: 100%;
margin: 0px;
}
.outter {
display: flex;
flex-direction: column;
height: 100%;
background-color: red;
}
.header {
background-color: gray;
height: 3em;
}
.content {
height: 100%;
background-color: green;
}
.footerClass {
background: yellow;
height: 3em;
}
.tableClass {
margin: 10px;
height: 100%;
width: 100%;
border: 2px solid;
border-collapse: collapse;
border-spacing: 0;
}
.tableClass th,
.tableClass td {
border: 1px solid black;
}
<div class="outter">
<div class="header">This is a header</div>
<div class="content">
<table class="tableClass">
<thead>
<tr>
<th>COL 1</th>
<th>COL 2</th>
<th>COL 3</th>
<th>COL 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>This is some text in row 1</td>
<td>1</td>
<td>3</td>
</tr>
<tr>
<td>2</td>
<td>This is some text in row 2</td>
<td>1</td>
<td>3</td>
</tr>
<tr>
<td>3</td>
<td>This is some text in row 3</td>
<td>3,4,5</td>
<td>1</td>
</tr>
<tr>
<td>4</td>
<td>This is some text in row 4</td>
<td>2,6,7</td>
<td>2</td>
</tr>
</tbody>
</table>
<div>
Another Div
</div>
<div class="footerClass">
This is a footer
</div>
</div>
</div>
【问题讨论】:
-
所有你的 div(除了表格)都有固定的或动态的高度吗?
-
不,我希望表格和页脚之间的任何 div 都具有固定高度、根据需要占用垂直空间或百分比的能力。
标签: html css html-table flexbox