I. Objective: Understand the basic principles of CSS Grid and how it differs from other layout techniques like Flexbox.
II. Topics Covered:
What is CSS Grid?
Introduction to CSS Grid as a 2-dimensional layout system.
Advantages over traditional layout methods.
Defining a Grid Container
display: grid; vs. display: inline-grid;
display: grid;
display: inline-grid;
Grid Lines and Tracks
Columns, rows, and grid lines.
Defining columns and rows using grid-template-columns and grid-template-rows.
grid-template-columns
grid-template-rows
The fr Unit
fr
Introduction to the fractional unit and its role in responsive grids.
III. Activity:
Create a simple grid container with three columns and two rows.
Set up grid-template-columns: 1fr 1fr 1fr; and grid-template-rows: 100px 200px;.
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 100px 200px;
Add items to the grid and observe how they fill the grid cells.
IV. Homework/Practice:
Build a four-column layout using CSS Grid, adjusting column widths with different fractional values (e.g., 1fr, 2fr, 3fr, 1fr).
1fr
2fr
3fr
Last updated 1 year ago