css - 在 body 的孩子上设置 100% 会溢出页面
问题描述
这是CSS
body, html {
height: 100%;
width: 100%;
}
#container {
display: flex;
position: absolute;
flex-flow: column wrap;
justify-content: stretch;
align-items: center;
width: 100%;
height: 100%;
text-align: center;
background-color: black;
}
div.sections {
display: flex;
flex-flow: row wrap;
justify-content: left;
align-items: stretch;
margin: 0;
padding: 0;
width: 100%;
color: black;
background-image: linear-gradient(0, orange, gold);
border-top: 2px solid black;
border-bottom: 2px solid black;
}
哪里#container
是 的兄弟div.sections
,都在 body 标签下。问题是#container
' 的高度超出了身体div.sections
的高度。我不知道这里有什么问题,或者它是否与 flex 有关。我确实知道如何用 javascript 解决它,但我真的很想在 css 中看到解决方案。
解决方案
我试图为您的父母设置一个特定的高度值div.sections
,height: 500px;
这将解决您的问题。谢谢
div.sections {
display: flex;
flex-flow: row wrap;
justify-content: left;
align-items: stretch;
margin: 0;
padding: 0;
height: 500px; /* Height Value as you want */
width: 100%;
color: black;
background-image: linear-gradient(0, orange, gold);
border-top: 2px solid black;
border-bottom: 2px solid black;
}
推荐阅读
- javascript - 在另一个 fetch API 之后更新状态值
- python - 构建 CNN 模型时出错,目标大小与样本大小不同
- google-apps-script - 从 Label 中的必要 OU 复制公司邮件
- c# - 通过方程式更改所有按钮的背景颜色
- c# - Razor 中不正确的三元运算
- bash - 从 bash 脚本运行 makefile 命令并返回错误结果代码
- java - 如何在 recyclerview 适配器类中发送广播?
- c# - c# SpecFlow,如何从 ScenarioContext(或其他测试上下文)获取场景中的示例行索引
- node.js - Azure 资源管理器身份验证失败
- python - 类型错误:+ 的不支持的操作数类型:“int”和“str”在之前执行良好的程序中