UNIT 9 • STAGE 2 OF 7
Use Flexbox to add an image to the hero and build four concept cards
Flexbox is a CSS layout tool that arranges items in a row or a column and lets them share space intelligently. You set display: flex on a container, and its children arrange themselves inside it.
In this stage you will use Flexbox twice: first to split the hero section into two columns (text on the left, an image on the right), then to lay out four concept cards in a row that wraps on smaller screens.
Here is what you are building:
Your research paragraph text sits here on the left, with space to breathe.
Food Sovereignty Pillars
Four concept cards in a Flexbox row below the hero.
Reliable access to nutritious food.
The ability to reach and afford food nearby.
The right to save and share traditional seeds.
Decisions that serve people seven generations out.
Your editor already has the Stage 1 code loaded: the hero section with its styles. You will add new CSS and update the hero HTML first, then add the pillars section below it.
Find </style> in your editor. Add this CSS just above it. It creates the two-column layout inside the hero:
display: flex on .hero-inner, turns the container into a Flexbox row. Its two children (text and image) sit side by side.align-items: center, vertically centers the text column and image column relative to each other. Without this, the text would align to the top.gap: 60px, space between the text and the image. More generous than the card gaps because the hero deserves breathing room.max-width: 1100px; margin: 0 auto, centers the layout and prevents it from stretching across very wide screens.flex: 1 on .hero-text, the text column grows to fill all available space that the image column does not take.flex: 0 0 360px on .hero-image, the image column is fixed at exactly 360px. It does not grow and it does not shrink. The three values mean: do not grow (0), do not shrink (0), start at 360px.object-fit: cover on the img, fills the image box without distorting the photo. The image crops to fit rather than squishing.height: 300px, a consistent image height. Without this, the image would use its natural height which varies by photo.border-radius: 8px, rounds the image corners slightly so it feels at home on the page rather than like a clipped rectangle.Your current hero HTML has the content directly inside <section id="hero">. You need to wrap it in a new structure: a .hero-inner flex container holding a .hero-text div and a .hero-image div.
Replace the contents of your <section id="hero"> with this:
The src points to a photo from Unsplash. You already know how src works, replace that URL with any image you want. Paste a different Unsplash URL, link to a photo you have saved, or use a path to a file on your computer. The layout will adjust automatically.
Now add the concept card styles. Find </style> again and add this CSS just above it (after the hero image CSS you just added):
background: #e6f4ea on #pillars, a very light green that transitions from the deep hero green. The section colors move page-wide: dark forest green (hero), light sage green (pillars), and so on.flex-wrap: wrap on .pillars-grid, allows cards to drop to a new row on narrow screens. Without this the cards would shrink until they overflow.gap: 24px, equal spacing between every card both horizontally and vertically without separate margin values.flex: 1 1 220px on .concept-card, the card can grow (1), can shrink (1), and starts at 220px. On wide screens all four cards share the row equally; on narrow screens they wrap and stack.border-left: 4px solid #2d4a1e, a dark green accent bar that ties each card back to the hero's color, creating a visual thread from the top to the pillars section.Find the closing </section> tag after your hero content. Add this HTML right after it:
Your hero now has a two-column layout with an image, and the page has a second section with four food sovereignty concept cards in a Flexbox row. In Stage 3 you will add the recipes section with two traditional dishes using <ul> and <li> for ingredient lists.