html - 高度 100% 不起作用
问题描述
我做了网站,代码结构在这里。
<body>
<header></header>
<section></section>
<footer></footer>
</body>
在<section>
,我定义height: 100%
但它不能正常工作。
详细的部分标签在这里。
<section>
<div class="section-home">
<div class="menubox">1</div>
<div class="menubox">1</div>
<div class="menubox">1</div>
<div class="menubox">1</div>
<div class="menubox">1</div>
<div class="menubox">1</div>
</div>
</section>
当我创建很多 .box 时,它会像这样溢出。
(<section>
标签的背景色是浅灰色和footer
白色)
[CSS]
html, body {
width: 100%;
height: 100%;
}
section {
width: 100%;
height: 100%;
}
.section-home {
display: flex;
flex-shrink: 0;
flex-wrap: wrap;
justify-content: center;
height: 100%;
}
.menubox {
height: 350px;
width: 300px;
margin: 20px;
border: 0px solid lightgray;
border-radius: 0.5rem;
background-color: white;
padding: 10px;
-moz-box-shadow: 0px 5px 5px lightgray;
-webkit-box-shadow: 0px 5px 5px lightgray;
box-shadow: 0px 5px 5px lightgray;
}
我该如何解决这个问题?
谢谢。
解决方案
将高度更改为最小高度。
section {
width: 100%;
min-height: 100%;
}
推荐阅读
- docker - Docker:将文件从容器写入主机上的卷
- neo4j - Neo4j 从图中获取嵌套对象数组的响应
- elixir - 为什么 Ecto.Repo 进程不需要`send/receive`?
- javascript - 如何在nestjs中使用自定义类文件维护nestjs的规则
- file - NetSuite:读取文件柜中的csv类型文件时出现乱码
- gcc - 使用 ARM GCC 时,什么是“nosys”、“nano”、“rdimon”术语?
- machine-learning - 确定梯度下降的起点
- c - .pxd 文件中的 Cython 构造函数重载错误:工厂函数的“C 方法的自参数与父类型不匹配”
- python-3.x - Pandas 跨行的最小值和最大值
- java - Android:如何在 MapBox 中添加自定义标记?