我试图制作一些可以在电视屏幕上运行的东西,分辨率会很高但可能是任何东西。
我已经提出了几乎可以使用的以下HTML / CSS组合(但是,如果高度太小,表格会与页脚底部重叠,而表格右侧的填充与右手重叠侧)
可以在这里找到一个JS小提琴:http://jsfiddle.net/hyLrj2t4/
HTML:
<div class="flexbox-parent">
<div class="flexbox-item header">
Header
</div>
<div class="flexbox-item fill-area content flexbox-item-grow">
<div class="fill-area-content flexbox-item-grow">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0000"> </td>
</tr>
<tr>
<td bgcolor="#00FF00"> </td>
</tr>
<tr>
<td bgcolor="#0000FF"> </td>
</tr>
<tr>
<td bgcolor="#FF0000"> </td>
</tr>
<tr>
<td bgcolor="#00FF00"> </td>
</tr>
<tr>
<td bgcolor="#0000FF"> </td>
</tr>
</table>
</div>
</div>
<div class="flexbox-item footer">
Footer
</div>
</div>
CSS:
*, *:before, *:after
{
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html, body
{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body
{
background: #444444;
color: #cccccc;
font-size: 14px;
/* Helvetica/Arial-based sans serif stack */
font-family: Frutiger, "Frutiger Linotype", Univers, Calibri, "Gill Sans", "Gill Sans MT", "Myriad Pro", Myriad, "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.flexbox-parent
{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start; /* align items in Main Axis */
align-items: stretch; /* align items in Cross Axis */
align-content: stretch; /* Extra space in Cross Axis */
background: rgba(255, 255, 255, .1);
}
.flexbox-item
{
padding: 0.5%;
}
.flexbox-item-grow
{
flex: 1; /* same as flex: 1 1 auto; */
}
.flexbox-item.header
{
background: rgba(255, 0, 0, .1);
}
.flexbox-item.footer
{
background: rgba(0, 255, 0, .1);
}
.flexbox-item.content
{
background: rgba(0, 0, 255, .1);
}
.fill-area
{
display: flex;
flex-direction: row;
justify-content: flex-start; /* align items in Main Axis */
align-items: stretch; /* align items in Cross Axis */
align-content: stretch; /* Extra space in Cross Axis */
}
.fill-area-content
{
background: rgba(0, 0, 0, .3);
border: 1px solid #000000;
/* Needed for when the area gets squished too far and there is content that can't be displayed */
overflow: auto;
}
table{
height:88%;
position:absolute;
}
可以在黄色方块中看到违规物品:
答案 0 :(得分:0)
如果我正确地看到整个布局可以在没有flex
的情况下完成,请参阅以下简化演示。
html, body {
margin: 0;
height: 100%;
}
.container {
display: table;
width: 100%;
height: 100%;
background: #333;
color: white;
}
.container > div {
display: table-row;
}
.container > div > div {
display: table-cell;
}
.container > div:nth-child(2) > div {
height: 100%;
}
.container table {
border-collapse: collapse;
width: 100%;
height: 100%;
}
<div class="container">
<div><div>Header</div></div>
<div>
<div>
<table>
<tr><td bgcolor="#FF0000"></td></tr>
<tr><td bgcolor="#00FF00"></td></tr>
<tr><td bgcolor="#0000FF"></td></tr>
<tr><td bgcolor="#FF0000"></td></tr>
<tr><td bgcolor="#00FF00"></td></tr>
<tr><td bgcolor="#0000FF"></td></tr>
</table>
</div>
</div>
<div><div>Footer</div></div>
</div>