grid-template-rows: Repeat(auto-fill, 80px) 可以与 grid-auto-rows: 80px 互换使用吗?
P粉823268006
P粉823268006 2023-09-12 21:10:45
0
1
395

我希望网格在添加动态内容时根据需要添加更多行。

这就能解决问题:

.grid {
  display: grid;
  grid-template-rows: 80px;
  grid-auto-rows: 80px;
//  grid-template-rows: repeat(auto-fill, 80px);
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  grid-gap: 60px 60px;
}

我想知道是否可以使用grid-template-rows:repeat(auto-fill, 80px);来代替grid-auto-rows: 80px

P粉823268006
P粉823268006

répondre à tous(1)
P粉627136450

嗯,grid-template-rows: Repeat(auto-fill, 80px); 是根据 规范,但它没有给出所需的结果。相反,它只是创建一个高度为 80 像素的显式行,并且其他行会自动调整大小。

但是,由于您希望根据需要添加行,即隐式创建的网格行,因此您应该使用 grid-auto-rows 并且无需使用grid-template-rows

.grid {
  display: grid;
  grid-auto-rows: 80px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 60px;
  }

.grid div {
  background-color: silver;
}
<div class="grid">
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
</div>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!