Home > Article > Web Front-end > How to Achieve Auto-Height Rows in Nested CSS Grids?
CSS Grid Layout: Auto Height Rows with Content-Based Sizing
In this scenario, you have a grid design with two nested grids. While the left nested grid behaves as expected, the height of the rows in the right nested grid is set to match the height of the rows in the left grid.
Setting the grid-auto-rows property to max-content in the right nested grid will allow its rows to adjust to the height of their content, resolving the issue and ensuring that both nested grids have rows of equal height:
.grid-3 { grid-auto-rows: max-content; }
With this modification, the rows in the right nested grid will automatically scale to fit their content, maintaining the desired visual balance between the two grids.
The above is the detailed content of How to Achieve Auto-Height Rows in Nested CSS Grids?. For more information, please follow other related articles on the PHP Chinese website!