Home > Web Front-end > CSS Tutorial > How to Achieve Auto-Height Rows in Nested CSS Grids?

How to Achieve Auto-Height Rows in Nested CSS Grids?

Mary-Kate Olsen
Release: 2024-11-23 10:20:10
Original
492 people have browsed it

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;
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template