UNIT 10 • STAGE 4 OF 7

Hover Effects

Make the cards lift, scale, and glow when a visitor hovers over them

UNIT
STEP 1

Three Layers of Hover

The hover effect you are about to build has three parts working together. Each one adds a different quality to the interaction:

  • The card lifts, transform: translateY(-6px) moves the card 6 pixels upward, creating the illusion it is rising off the page. A warm gold box shadow fades in beneath it.
  • The image scales, transform: scale(1.06) makes the dancer illustration grow slightly. Since the card has overflow: hidden, the edges clip and it looks like the image is zooming in from within the card.
  • A gold overlay fades in, a ::before pseudo-element sits over the card as an invisible gold tint. On hover, its opacity transitions from 0 to 1, washing the card in a warm glow.

Hover over the right card below to see all three working at once:

No hover
Hover me
STEP 2

Add the Card Hover CSS

Find the .dancer-card rule and add transition to it. Then add the five new rules below it, all just above </style>:

👉 Update .dancer-card, add transition to the existing rule: .dancer-card {
  /* ... existing properties ... */
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
👉 Add these five rules just above </style>: .dancer-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 48px rgba(212, 168, 83, 0.25);
}

.dancer-card img {
  /* ... existing properties ... */
  transition: transform 0.4s ease;
}

.dancer-card:hover img {
  transform: scale(1.06);
}

.dancer-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(212, 168, 83, 0.12);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.dancer-card:hover::before {
  opacity: 1;
}

Also update .card-label, change its z-index from 1 to 2 so it stays above the new ::before overlay:

👉 Update z-index in .card-label: .card-label {
  /* ... existing properties ... */
  z-index: 2;
}
STEP 3

Why These Styles?

  • transition: transform 0.3s ease, box-shadow 0.3s ease on .dancer-card, tells the browser to animate both the lift and the shadow over 300 milliseconds with an ease curve. Without this, both changes would snap instantly on hover.
  • transform: translateY(-6px) on hover, moves the card upward by 6 pixels. The movement is purely visual and does not affect the layout of other elements around it.
  • box-shadow: 0 16px 48px rgba(212, 168, 83, 0.25), a large soft shadow in a warm gold tone. The 0 horizontal offset centers it. 16px vertical offset pushes it down. 48px blur spreads it wide. 0.25 opacity keeps it subtle.
  • transform: scale(1.06) on hover image, scales the image to 106% of its size. The overflow: hidden on the card clips the excess, so the image appears to zoom in from within the card frame.
  • ::before pseudo-element, creates a generated element that acts as an invisible overlay layer. It occupies the full card area via inset: 0 (a shorthand for setting all four sides to 0). At opacity: 0 it is invisible; at opacity: 1 on hover it becomes a warm gold tint.
  • z-index: 2 on .card-label, keeps the dance name readable above the ::before overlay, which sits at z-index: 1.

Stage 4 Complete!

Your cards now respond to hover with a lift, a zoom, and a gold glow. In Stage 5 you will build the modal, the popout window that will appear when a visitor clicks a card. The modal is all HTML and CSS in this stage. JavaScript comes in Stage 6.

Code Editor
Live Preview