【发布时间】:2020-06-08 02:13:15
【问题描述】:
我在响应式设置网格容器时遇到问题,以便将其高度拉伸到内容。调整窗口大小时,网格本身会正常运转,不幸的是,即使我使用 min-height 属性,容器仍保持相同的高度,这导致仅显示 9 个单元格中的 3 个。溢出:可见也不能解决我的问题。感谢您的帮助!
CSS:
#grid_content {
position: absolute;
right: 0;
top: 100px;
width: calc(100% - 220px);
padding-bottom: 50px;
z-index: -1;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
grid-template-rows: repeat(auto-fit, minmax(250px, 28vh));
min-height: 80vh;
}
.grid {
position: relative;
width: 100%;
height: 100%;
display: block;
float: left;
}
【问题讨论】:
-
添加html内容进行说明
-
寻求代码帮助的问题必须包含重现它所需的最短代码在问题本身中最好在Stack Snippet 中。见How to create a Minimal, Reproducible Example
标签: html css responsive-design css-grid