为什么fit-content()在CSS-Grid中不适用于网格 - 板行属性,但在网格板柱上效果很好?
我举一个例子,在哪里有两个图像。它们的尺寸为168px宽度和180个高度。我只允许使用高达300px的高度,但是它垂直呈现目标两个图像,而网格 - 板块柱并非如此,一切正常。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HAYTI</title>
<style>
.grid {
display: grid;
border: 2px solid black;
grid-template-columns: 200px 1fr;
grid-template-rows: fit-content(300px) 100px ;
height: 600px;
background: orange;
}
.itemm {
border: 2px solid black;
}
.item1 {
font-size: 20px;
background: lime;
padding: 5px;
}
.item2 {
background: red;
font-size: 20px;
}
</style>
</head>
<body>
<section class="grid">
<div class="itemm item1"><img src="https://i.sstatic.net/28qba.jpg"> <img src="https://i.sstatic.net/28qba.jpg"></div>
<div class="itemm item2">item2</div>
<div class="itemm item2">item3</div>
<div class="itemm item2">item3</div>
</section>
</body>
</html>
I'll give one example, where have two images. size of them is 168px-width and 180-height. I only allowed to use up to 300px height, but it renders the target two images vertically, which is not the case with grid-template-columns, where everything works fine.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HAYTI</title>
<style>
.grid {
display: grid;
border: 2px solid black;
grid-template-columns: 200px 1fr;
grid-template-rows: fit-content(300px) 100px ;
height: 600px;
background: orange;
}
.itemm {
border: 2px solid black;
}
.item1 {
font-size: 20px;
background: lime;
padding: 5px;
}
.item2 {
background: red;
font-size: 20px;
}
</style>
</head>
<body>
<section class="grid">
<div class="itemm item1"><img src="https://i.sstatic.net/28qba.jpg"> <img src="https://i.sstatic.net/28qba.jpg"></div>
<div class="itemm item2">item2</div>
<div class="itemm item2">item3</div>
<div class="itemm item2">item3</div>
</section>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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