UNIT 9 • STAGE 7 OF 7
Add hover animations that make the page feel alive
A CSS transition tells the browser: when a property changes, do not snap to the new value instantly. Instead, animate the change smoothly over a set amount of time.
Right now your cards appear and disappear abruptly when you hover over them (because there is no hover state yet). After this stage, hovering a card will cause it to gently rise and cast a deeper shadow, then settle back down when you move away. Hover over the cards below:
That lift effect is built with two CSS properties: transition and transform.
transition, tells the browser to animate changes to specific properties over a duration with a timing curvetransform: translateY(-4px), moves the element 4 pixels upward. Combined with a transition, this creates the liftbox-shadow, a shadow around the card that deepens on hover, reinforcing the sense of the card lifting off the pageFind the .concept-card rule in your <style> block. You will modify it to add a transition, then add a new :hover rule below it:
Do the same for the recipe cards. Find .recipe-card and add the transition, then add the :hover rule below it:
transition: transform 0.3s ease, box-shadow 0.3s ease, the three parts are: what to animate (transform and box-shadow), how long (0.3 seconds), and the timing curve (ease, which starts fast and slows near the end). 0.3s is a widely used default: fast enough to feel responsive, slow enough to be visible.transform: translateY(-4px), moves the card 4 pixels upward along the Y axis. Negative values move up; positive values move down. This is the CSS way to lift a card without affecting its space in the layout: other cards do not reflow when one lifts.box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1), a soft shadow that appears below the card when hovered. The four values are: horizontal offset (0), vertical offset (8px below), blur radius (20px wide), and color (10% opacity black). A deeper, wider shadow on hover reinforces the visual metaphor of the card lifting toward the viewer.:hover rule) for the animation to play both on mouse-enter and mouse-leave. If you put it only on :hover, the card snaps back instantly when you move away.In the live preview, scroll to the pillars section and hover slowly over each concept card. You should see each card lift upward and cast a deeper shadow, then settle back when you move away. Do the same for the recipe cards.
Try changing 0.3s to 0.5s for a slower, more deliberate lift, or 0.15s for a snappier feel. The timing is a design choice: match it to the personality of the page.
You built a full food sovereignty resource page: a hero with research, four concept cards in a Flexbox layout, two recipe cards with ingredient lists, a styled HTML form with CSS focus states, a JavaScript interaction that responds to form submission, polish with spacing and a footer, and CSS transitions that bring the whole page to life. You wrote your first JavaScript. The page responds to the people who use it. That is a meaningful thing to have built.