![](/img/trans.png)
[英]How to make two images with different heights the same height with the respect of ratio?
[英]How do I make content of different heights the same height in css grid?
我正在创建一个垂直的单列列表。 有些文本是 200 个字符长,有些是 1 个字符。 并且列表宽度动态变化。
我如何动态地使每个高度相同?
所有条件都在下面。
有办法使高度统一为 200px,但我不喜欢它,因为它不是动态的。 当我们将每个高度设置为 200px 时,如果我们改变列表的宽度,布局就会被破坏。
这是现在。 如您所见,红色和蓝色的高度不同。 我希望这些都是一样的。
.grid {
height: 100vh;
overflow: scroll;
display: grid;
grid-template-rows: repeat(auto-fill, auto);
grid-template-columns: 1fr;
}
尝试这个:
.grid {
height: 100vh;
overflow: scroll;
display: grid;
/* grid-template-rows: 100px 100px; */
grid-template-rows: repeat(auto-fill, minmax(100px, 1fr));
grid-template-columns: 1fr;
}
.long-text {
background-color: red;
}
.short-text {
background-color: blue;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.