UNIT 10 • STAGE 3 OF 7

The Dancer Images

Add the illustrated dancer images to each card

UNIT
STEP 1

How Images Work Inside Cards

Right now each card is a solid dark box with a dance name at the bottom. In this stage you will add an illustrated dancer image inside each card. Because the images are PNGs with transparent backgrounds, the card's own dark color will show through wherever the illustration has no content, creating a clean, layered look.

The image needs to fill the card completely and sit behind the dance name label. To do this, you will position the image absolutely inside the card. The card already has position: relative, which makes it the reference point for anything positioned absolutely inside it.

Why object-fit: contain?

In Unit 06 you used object-fit: cover to fill a box by cropping a photo. These dancer images are illustrations with transparent backgrounds, cropping them would cut off feet or headdresses. object-fit: contain shows the full illustration, scaled to fit, without cropping anything.

STEP 2

Update the Card CSS

Find the .card-label rule in your CSS and replace it with this updated version, then add the new .dancer-card img rule directly below it:

👉 Replace .card-label and add .dancer-card img below it: .card-label {
  width: 100%;
  padding: 20px;
  color: white;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  position: relative;
  z-index: 1;
  background: linear-gradient(to top, rgba(26, 18, 55, 0.92), transparent);
}

.dancer-card img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}
STEP 3

Add an Image to Each Card

Inside each .dancer-card, add an <img> tag before the <span>. The image path uses ../../assets/images/ to navigate two folders up from unit-10/ to the project root, then into the assets folder. Here are all six, add the matching <img> to each card:

👉 Jingle Dress card, add img before the span: <div class="dancer-card">
  <img src="../../assets/images/womensJingle.png" alt="Jingle Dress dancer">
  <span class="card-label">Jingle Dress</span>
</div>
👉 Fancy Shawl card: <img src="../../assets/images/womensFancy.png" alt="Fancy Shawl dancer">
👉 Women's Traditional card: <img src="../../assets/images/womensTraditional.png" alt="Women's Traditional dancer">
👉 Grass Dance card: <img src="../../assets/images/mensGrass.png" alt="Grass Dance dancer">
👉 Men's Traditional card: <img src="../../assets/images/mensTraditional.png" alt="Men's Traditional dancer">
👉 Men's Fancy card: <img src="../../assets/images/mensFancy.png" alt="Men's Fancy dancer">
STEP 4

Why These Styles?

  • position: absolute on .dancer-card img, removes the image from normal document flow and positions it relative to the nearest positioned ancestor, which is the card. It fills the entire card area without pushing the label out of position.
  • object-fit: contain, scales the illustration to fill as much of the card as possible without cropping. The full dancer figure stays visible, which matters for regalia, cutting off a headdress or moccasins would lose important detail.
  • object-position: center bottom, anchors the contained image to the bottom center of the card. The dancer's feet sit at the card's base, which feels natural and grounds the figure visually.
  • position: relative; z-index: 1 on .card-label, ensures the dance name text appears above the absolutely positioned image. Without this, the label would be hidden behind the image.
  • background: linear-gradient(...) on .card-label, fades from the card's dark indigo at the bottom to transparent at the top. This creates a readable area for the text without a hard-edged box, so the label blends naturally into the illustration above it.

Stage 3 Complete!

Your grid now shows the six dancer illustrations inside their cards with the dance name readable at the bottom. In Stage 4 you will add the hover effects: the card lifts, the image scales up slightly, and a gold tint overlay fades in when a visitor moves their mouse over a card.

Code Editor
Live Preview