CSS grid-row-end Property
Subject: css
CSS grid-row-end Property
The grid-row-end property in CSS Grid specifies the end line of a grid item on the vertical (row) axis. It determines where a grid item stops and can be used to span multiple rows or stop at a specific line.
Why Use grid-row-end?
- Control how many rows an item should occupy
- Build complex or staggered layouts
- Enable flexible designs like masonry-style grids
- Avoid nested structures by using grid features
Syntax
Values
line number: Ends the item at a specific grid line (e.g.,grid-row-end: 4)span <number>: Makes the item span across that many rows (e.g.,grid-row-end: span 2)
Example: Spanning Rows with grid-row-end
Explanation
.item1starts at row 1 and spans 2 rows usinggrid-row-end: span 2.item2starts at row 2 and ends exactly at row line 4 (spans rows 2 and 3)- Other items are placed automatically by the grid
Best Practices
- Use
spanfor content that should span a set number of rows - Use specific line numbers for structured layouts
- Always combine with
grid-row-startfor full control - Keep track of row line positions in fixed templates
Common Use Cases
- Magazine or blog-style cards
- Featured content sections with taller elements
- Product listings with flexible row spans
- Pinterest-style layout designs
Key Takeaways
grid-row-enddefines where a grid item ends vertically- Use
spanfor dynamic row height - Use a line number for exact row placement
- Combine with
grid-row-startfor vertical grid control - Requires
display: gridon the parent container
Advertisement Slot 1
Advertisement Slot 2