【问题标题】:Cannot manage to have heights relative to items contents with css grid无法使用css网格管理相对于项目内容的高度
【发布时间】:2019-07-30 15:50:11
【问题描述】:

目前,当我使用网格创建 CSS 布局时,此布局中的项目将占据最高项目的高度。是否可以让项目只占用其内容所需的高度?

https://codepen.io/anon/pen/NQpQOr

在此示例中,我希望 div2 具有相对于其内容的高度。

【问题讨论】:

标签: html css css-grid


【解决方案1】:

您可以使用align-self 属性来修复它:

.div-2 {
  align-self: start;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-26
    • 2018-03-30
    • 1970-01-01
    • 2018-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-30
    相关资源
    最近更新 更多