Nearby lessons
7 of 15š§© CSS Grid Item
š What are CSS Grid Items?
A grid item is a direct child of a grid container. š¦ It can be precisely placed and aligned within the grid using powerful properties.
These properties help control the item's position, span, and alignment within grid cells:
š§ Key Capabilities
- š Position items using
grid-columnandgrid-row - šÆ Align items with
justify-selfandalign-self - š Use
place-selfas a shorthand
šØ Overview
Let's explore each property with examples to understand how grid items behave and align themselves inside a grid layout. šØš
šø grid-column / grid-row
| Attribute | Value | Description |
|---|---|---|
grid-column | 1 / 3 | Span from column line 1 to 3 |
grid-row | 2 / 4 | Span from row line 2 to 4 |
grid-column | span 2 | Span across 2 columns |
grid-row | span 3 | Span across 3 rows |
š grid-column: 1 / 3
Spans item from column line 1 to 3.
Code Example
PREVIEW READY
Keep Going!CSS - Animations