网格 - 自动行.VS Min-Height。有什么区别?
这两个代码之间有什么区别?使用网格 - 自动行
的优点是什么优点,而我们可以使用更简单的规则(例如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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论