【发布时间】:2021-12-03 01:30:00
【问题描述】:
每当我缩小到最大,在我的框 5“页脚”下方时,我的“网站”就有问题。 有这么大量的空白,我不想要。 我想我需要以某种方式调整我的网站大小,比如给页面一个水平和垂直的最大值。不确定这是否适用于网格。我认为另一种解决方案可能是让 box2 和 4 水平最大值,并让页眉和页脚始终处于粘性状态,并将 box 3 设为自动。 我一直坚持如何解决它。在 stackoverflow 上看到另一篇关于有人如何解决它的帖子,但它不适用于我的。
在我解决了这个问题之后,我的目标是让框 1 2、4 和 5 具有粘性或类似的东西,所以它会随着页面滚动。并将框 3 作为内容。
.grid {
display: grid;
grid-template-columns: 1fr 4fr 1fr;
background-color: #8b9dc3;
height: 100vh;
}
.box1 {
background-color: #3b5998;
grid-column: 1/4;
grid-row: 1/2;
z-index: 2;
}
.box2 {
grid-column: 1;
/* grid-row: 2/12; */
grid-row-start: 2;
grid-row-end: 12;
}
.box3 {
background-color: #ffffff;
grid-row: 2/12;
grid-column: auto;
}
.box4 {
align-self: stretch;
grid-column: 3;
grid-row: 2/12;
grid-row: 2 / max;
}
.box5 {
background-color: #3b5998;
grid-column: 1/4;
}
html,
body {
margin: 0;
padding: 0;
overflow: hidden;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="mystylesheet2.css">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="grid">
<div class="box box1">box1</div>
<div class="box box2">box2</div>
<div class="box box3">box3</div>
<div class="box box4">box4</div>
<div class="box box5"> box5</div>
</div>
</body>
</html>
【问题讨论】: