CSS Grid - Auto height rows, sizing to content

后端 未结 3 2127
花落未央
花落未央 2020-11-30 03:23

I have two grids nested within a grid. Unfortunately the right nested grid .grid-3 sets the height of the rows so that both the left and right grid are the same

3条回答
  •  清歌不尽
    2020-11-30 03:40

    You can also try grid-auto-rows: fit-content(1em);. Of course, use whatever sizing makes sense for you. I also tried the approach described by Temani (minmax(min-content, max-content)) and the results were identical when rendering my HTML.

    According to Elad Schechter - Medium,

    The fit-content function accepts one param, the maximum value. ... The fit-content() function is similar to using the minmax() function, with a minimum value of 0. One key difference: The minmax() is more likely to occupy the max space allowed, while the fit-content does not occupy any more space than necessary.

    Your needs will determine whether fit-content is more appropriate than using minmax and vice-versa.

提交回复
热议问题