html - 使第二个子元素符合父高度且不重叠
问题描述
我有第二个子元素section.nested
超过父 div 高度的问题。我已经尝试过,但无法使其符合父母的div
任何想法?
html,body,main {
height: 100%
}
main {
display: flex;
flex-direction: column;
}
main > section {
min-width: 31%;
max-width: 74%;
max-height: 74%;
padding: 1.27rem;
background-color: #575757;
}
main > section > div {
height: 100%;
max-height: 100%;
}
main section.nested {
padding: 1rem;
background-color: #ccc;
}
article {
height: 600px;
background-color: #eee
}
<main>
<section>
<div>
<header>
<h3>heading</h3>
<p>Some text</p>
</header>
<section class="nested">
<div>
<article></article>
</div>
</section>
</div>
<section>
</main>
我有兴趣只是section.nested
遵守而不给出明确px
的高度,其余的溢出无关紧要
解决方案
删除 最大高度:74%;主要 > 部分的属性
html,body,main {
height: 100%
}
main {
display: flex;
flex-direction: column;
}
main > section {
min-width: 31%;
max-width: 74%;
padding: 1.27rem;
background-color: #575757;
}
main > section div {
height: 100%;
max-height: 100%;
}
main section.nested {
padding: 1rem;
background-color: #ccc;
}
article {
height: 600px;
background-color: #eee
}
<main>
<section>
<div>
<header>
<h3>heading</h3>
<p>Some text</p>
</header>
<section class="nested">
<div>
<article></article>
</div>
</section>
</div>
<section>
</main>
推荐阅读
- python - 如何修复此“TypeError:float() 参数必须是字符串或数字,而不是‘方法’”错误?
- hibernate - 使用 SpringBoot Hibernate 和 Maven 的 Oracle 数据库连接错误
- c# - 将投影点映射到真实世界的点
- c# - 从 32 位应用程序获取 64 位应用程序的进程信息
- django - Python 3 TypeError:需要字符串参数,得到 'bytes' casperjs_capture
- postgresql - 将列上的纪元时间保存到另一列 postgres
- c++ - 使用 cblas_dgemm 计算伪逆的问题
- excel - 在 python 中将文件作为命令行参数的输入
- multithreading - JMeter:如何在特定范围内生成 2 个随机浮点数并进一步使用它
- sql-server - SSIS:将 XML 文件内容传递给存储过程