网格 - 自动行.VS Min-Height。有什么区别?

发布于 2025-02-03 09:14:21 字数 679 浏览 1 评论 0原文

这两个代码之间有什么区别?使用网格 - 自动行的优点是什么优点,而我们可以使用更简单的规则(例如min-height-height)来实现相同的结果?我个人找不到主要区别!

在第一个中,我使用网格 - 自动行来控制行的高度。

.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(100px , auto);
}

.item {
  border: 2px solid blue;
  background-color: bisque;
}

在以下代码中,我使用了孩子的最小,以实现相同的结果。

.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.item {
  border: 2px solid blue;
  background-color: bisque;
  min-height: 100px;
}

我知道,从开发人员的角度来看,第一个可能会更好,因为此主题的用户无需将类“项目”应用于所有子女元素。但是,我很想知道最终输出是否有任何差异。

What is the difference between these two codes? What is the advantage of using grid-auto-rows while we can simply achieve the same result using a more simple rule such as min-height? I personaly cannot find a major difference!

In the first one, I used grid-auto-rows to control the height of rows.

.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(100px , auto);
}

.item {
  border: 2px solid blue;
  background-color: bisque;
}

In the following code, I used min-height of the children in order to achieve the same result.

.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.item {
  border: 2px solid blue;
  background-color: bisque;
  min-height: 100px;
}

I know that from the developer's point of view, the first one might be better because the user of this theme do not need to apply class "item" to all the children elements. However, I am curious to know if there is any differences in the final output.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文