我正在尝试制作一个基于百分比的div - 并试图在div中包含一个div。我希望中心(xyz div)只有它从content-div获得的大小的90%(高度)。我如何使一个div包含在一个flex div内
我希望“content”div能够响应90%中心div高度(页眉和页脚之间)。现在 - 基于浏览器大小完成拍摄。
我的代码是https://jsfiddle.net/thbx4pv2/
CSS
html,
body {
height: 100%;
margin: 0
}
.box {
display: flex;
flex-flow: column;
height: 100%;
font-size: 4em;
}
.box .row {
border: 1px dotted grey;
flex: 0 1 30px;
}
.box .row.header {
flex: 0 1 auto;
}
.box .row.content {
flex: 1 1 auto;
}
.box .row.footer {
flex: 0 1 40px;
}
.xyz {
position: absolute;
margin: 10 10 10 10 ;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 70%;
height: 90%;
overflow: auto;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
}
HTML
<div class="box">
<div class="row header">
<p><b>header</b>
</div>
<div class="row content">
<div class="xyz">
<p>
<b>content</b> (fills remaining space)
</p>
</div>
</div>
<div class="row footer">
<p><b>footer</b> (fixed height)</p>
</div>
</div>
你可以发布你想要的最终结果的图像吗? –
需要图片 - http://imgur.com/J5rzMnb。我希望“内容”div能够响应中心div的90%高度(页眉和页脚之间) – hypermails