我有一个包含标题/内容/页脚的HTML页面,它使用了flexbox模型并包含<details>
标记。 我需要使细节内容使用最大可用高度,这意味着当处于打开状态时,它的内容应该占据其容器中的所有空间(当然是概要除外)。制作HTML5详细信息标记以获取最大可用高度
这里是我的HTML/CSS代码(http://jsfiddle.net/rtojycvk/2/):
HTML:
<div class="wrapper">
<div class="header">Header</div>
<div class="main">
Some text before details
<details class="details" open>
<summary>Details summary</summary>
<div class="content">Details content</div>
</details>
</div>
<div class="footer">Footer</div>
</div>
CSS:
html, body {
height: 100%;
margin: 0; padding: 0;
}
.wrapper {
display: flex;
flex-direction: column;
width: 100%;
min-height: 100%;
}
.header {
height: 50px;
background-color: yellow;
flex: 0 0 auto;
}
.main {
background-color: cyan;
flex: 1;
display: flex;
flex-direction: column;
}
.footer {
height: 50px;
background-color: green;
flex: 0 0 auto;
}
.content {
background-color: blue;
color: white;
flex: 1;
}
.details {
background-color: red;
flex: 1;
display: flex;
flex-direction: column;
}
正如你所看到的,细节标签本身通吃可用空间,但不包含其内容。
P.S.我需要这个只在Chrome中工作。
尝试添加.content {height:100vh;} –
它使内容高度等于窗口高度,而不是我想要的 – Norfolc
“我需要使细节内容使用最大可用高度。”它会使内容细节填充详细信息摘要容器。 –