UNIT 10 • STAGE 2 OF 7
Build the six-card layout using CSS Grid
CSS Grid is a layout system built for two-dimensional arrangements, rows and columns at the same time. You have already used Flexbox, which controls items along a single axis. Grid controls both axes simultaneously, making it ideal for card layouts, photo galleries, and any design where items need to line up both across and down the page.
The key property is grid-template-columns. It defines how many columns the grid has and how wide each one is. The value repeat(3, 1fr) tells the browser: create three columns, each taking one equal fraction of the available space.
Six items, three columns, two rows, the browser figures out the row count automatically. All you define is the column structure.
Use Flexbox when items flow in one direction (a nav bar, a hero with text and image). Use Grid when you want a structured two-dimensional layout (a card gallery, a calendar). Both are valuable, knowing when to reach for each one is a core web development skill.
Find </style> in your editor and add this CSS just above it, after the #hero a block:
Find </body> and add this new section just above it, after the closing </section> of the hero:
background: #0f0f1a on #dancers, an almost-black deep navy, even darker than the hero. The cards sit against this background, and the contrast is intentional: the illustrated dancer images in the next stage are colorful and luminous. A very dark backdrop makes them glow.display: grid on .dancers-grid, turns the container into a grid parent. Every direct child becomes a grid item automatically.grid-template-columns: repeat(3, 1fr), creates three equal columns. repeat(3, ...) is shorthand for writing 1fr 1fr 1fr. The fr unit means "fraction of available space", each column gets exactly one third.gap: 24px, sets the space between grid items in both directions. One value applies to both row gaps and column gaps.height: 420px on .dancer-card, a fixed height that gives each card a consistent tall portrait shape. Dancer illustrations are vertical by nature.position: relative on .dancer-card, prepares the card to be a positioning context. In the next stage, the dancer image will be positioned absolutely inside it.display: flex; align-items: flex-end on .dancer-card, pushes the dance name label to the bottom of the card, where it will sit over the dancer's feet.Your page now has a dark grid of six placeholder cards. In Stage 3 you will add the dancer illustration images, the PNGs saved in the assets folder, and update the card styles so each image fills the card and the dance name stays readable at the bottom.