如何使网格中的元素具有自己特定的高度?

huangapple go评论141阅读模式
英文:

How to make elements in grid to have their own specific height?

问题

这是以下的容器。<br/>
您已经注意到网格中最后一个元素(类似表格结构)看起来很奇怪。是的,它看起来很奇怪,因为它正在获取该行中存在的元素的最大高度。<br/>
我只是希望元素看起来像...<br/>

您能告诉我在我应用了grid的bodyContainer内部应该使用哪个CSS属性吗?<br/>
这是我应用的CSS。

.bodyContainer {
    margin-top: 3rem;
    padding: 0rem 2rem 0rem 2rem;
    display: grid;
    grid-template-columns: 25% 25% 25% 25%;
    justify-content: space-between;
}
英文:

如何使网格中的元素具有自己特定的高度?

This is the following Container. <br/>
You have noticed that last element in the grid (Table like Structure) looks weird. YES, it looks weird because it is taking the maximum height of the element present in that row. <br/>
I just want the element to be look like...<br/>
如何使网格中的元素具有自己特定的高度?

Can you help me what CSS property should be used inside bodyContainer where I applied grid. <br/>
This is the CSS I have applied.

.bodyContainer{
    margin-top: 3rem;
    padding: 0rem 2rem 0rem 2rem;
    display: grid;
    grid-template-columns: 25% 25% 25% 25%;
    justify-content: space-between;
}

答案1

得分: 1

你想添加align-items: start;样式。这将告诉每个子元素保持其自然高度。默认值是align-items: stretch;

英文:

You want to add the align-items: start; style. That will tell each child to be its own natural height. The default is align-items: stretch;

huangapple
  • 本文由 发表于 2023年8月5日 14:19:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76840389.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定