Project: Responsive Landing Page
In this project you'll style a complete, responsive landing page for Soko Fresh, an imaginary service that delivers fresh produce around Nairobi. You'll use custom properties, Flexbox, Grid, clamp(), transitions and a mobile-first media query: most of what this series has covered, working together.
Goal and features
The finished page will have:
- a sticky header with the logo on the left and navigation links on the right (Flexbox);
- a hero section with a headline, a call-to-action button and a "today's basket" card, stacked on phones and side by side on wider screens (Grid plus a media query);
- a features section whose cards reflow automatically (
auto-fitGrid); - numbered "how it works" steps created with CSS counters and
::before; - a call-to-action band and a footer, all themed through custom properties.
Build it step by step
Step 1: the HTML skeleton
Start with clean, semantic HTML (see Semantic HTML): a header with a nav, a main with four sections, and a footer. The full markup is in the final code below; style it one section at a time.
Step 2: design tokens and base styles
Put every colour and spacing value in custom properties so the whole theme lives in one place. --space uses clamp() so spacing grows a little on bigger screens.
:root {
--green: #15803d;
--green-dark: #14532d;
--accent: #f59e0b;
--ink: #1f2937;
--muted: #4b5563;
--surface: #f0fdf4;
--radius: 12px;
--space: clamp(1rem, 3vw, 2rem);
--max: 68rem;
}
*, *::before, *::after { box-sizing: border-box; }
body {
margin: 0;
font-family: system-ui, sans-serif;
color: var(--ink);
line-height: 1.6;
}
.container {
width: min(100% - 2rem, var(--max));
margin-inline: auto;
}
Step 3: the header with Flexbox
justify-content: space-between pushes the logo and the link list to opposite ends; flex-wrap lets the links drop below the logo on very small screens instead of overflowing.
.site-header {
background: var(--green-dark);
position: sticky;
top: 0;
z-index: 10;
}
.nav {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 0.5rem 1.5rem;
padding-block: 0.75rem;
}
.nav ul {
display: flex;
gap: 1rem;
list-style: none;
margin: 0;
padding: 0;
}
Step 4: the hero and a reusable button
The hero grid has one column by default. The headline uses clamp() for fluid type, and the button has a short transition and a clear focus style.
.hero-grid {
display: grid;
gap: var(--space);
align-items: center;
}
.hero h1 {
font-size: clamp(2rem, 6vw, 3.25rem);
line-height: 1.1;
}
.btn {
display: inline-block;
background: var(--accent);
color: var(--ink);
font-weight: 700;
padding: 0.75rem 1.5rem;
border-radius: 999px;
text-decoration: none;
transition: transform 0.2s ease, background-color 0.2s ease;
}
.btn:hover { background: #fbbf24; transform: translateY(-2px); }
.btn:focus-visible { outline: 3px solid var(--green-dark); outline-offset: 3px; }
Step 5: features and steps with Grid
The features grid needs no media query: each card is at least 14rem wide and the browser fits as many as it can. The steps use a CSS counter to generate the numbers in green circles.
.features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
gap: var(--space);
}
.steps {
display: grid;
gap: var(--space);
counter-reset: step;
list-style: none;
padding: 0;
}
.steps li {
counter-increment: step;
display: flex;
gap: 1rem;
}
.steps li::before {
content: counter(step);
flex: none;
display: grid;
place-items: center;
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
background: var(--green);
color: white;
font-weight: 700;
}
Step 6: the mobile-first media query
Everything so far works on a phone. One min-width query upgrades the layout once there's room:
@media (min-width: 48rem) {
.hero-grid { grid-template-columns: 3fr 2fr; }
.steps { grid-template-columns: repeat(3, 1fr); }
}
The complete page
Here is everything together. Press Try it, then resize the preview to watch the layout adapt.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Soko Fresh | Fresh produce delivered in Nairobi</title>
<style>
:root {
--green: #15803d;
--green-dark: #14532d;
--accent: #f59e0b;
--ink: #1f2937;
--muted: #4b5563;
--surface: #f0fdf4;
--radius: 12px;
--space: clamp(1rem, 3vw, 2rem);
--max: 68rem;
}
*, *::before, *::after { box-sizing: border-box; }
body {
margin: 0;
font-family: system-ui, sans-serif;
color: var(--ink);
line-height: 1.6;
}
.container { width: min(100% - 2rem, var(--max)); margin-inline: auto; }
/* Header */
.site-header { background: var(--green-dark); position: sticky; top: 0; z-index: 10; }
.nav {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 0.5rem 1.5rem;
padding-block: 0.75rem;
}
.logo { color: white; font-weight: 800; font-size: 1.25rem; text-decoration: none; }
.nav ul { display: flex; gap: 1rem; list-style: none; margin: 0; padding: 0; }
.nav a { color: white; text-decoration: none; }
.nav ul a:hover { color: var(--accent); }
/* Button */
.btn {
display: inline-block;
background: var(--accent);
color: var(--ink);
font-weight: 700;
padding: 0.75rem 1.5rem;
border-radius: 999px;
text-decoration: none;
transition: transform 0.2s ease, background-color 0.2s ease;
}
.btn:hover { background: #fbbf24; transform: translateY(-2px); }
.btn:focus-visible { outline: 3px solid var(--green-dark); outline-offset: 3px; }
/* Sections */
section { padding-block: calc(var(--space) * 2); }
.section-title { text-align: center; font-size: clamp(1.5rem, 4vw, 2.25rem); margin: 0 0 var(--space); }
/* Hero */
.hero { background: linear-gradient(135deg, var(--surface), #dcfce7); }
.hero-grid { display: grid; gap: var(--space); align-items: center; }
.hero h1 {
font-size: clamp(2rem, 6vw, 3.25rem);
line-height: 1.1;
margin: 0 0 1rem;
color: var(--green-dark);
}
.hero p { font-size: 1.125rem; color: var(--muted); max-width: 45ch; }
.basket {
background: white;
border-radius: var(--radius);
padding: var(--space);
box-shadow: 0 10px 30px rgb(0 0 0 / 10%);
}
.basket h2 { margin-top: 0; }
/* Features */
.features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
gap: var(--space);
}
.feature {
background: var(--surface);
border-top: 4px solid var(--green);
border-radius: var(--radius);
padding: var(--space);
}
.feature h3 { margin-top: 0; }
/* Steps */
.steps { display: grid; gap: var(--space); counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; display: flex; gap: 1rem; }
.steps li::before {
content: counter(step);
flex: none;
display: grid;
place-items: center;
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
background: var(--green);
color: white;
font-weight: 700;
}
.steps h3 { margin: 0.3rem 0 0.25rem; }
.steps p { margin: 0; color: var(--muted); }
/* Call to action and footer */
.cta { background: var(--green-dark); color: white; text-align: center; }
.cta h2 { margin-top: 0; font-size: clamp(1.5rem, 4vw, 2.25rem); }
.site-footer { background: #0f172a; color: #cbd5e1; padding-block: 1.5rem; font-size: 0.9rem; }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; }
/* Wider screens */
@media (min-width: 48rem) {
.hero-grid { grid-template-columns: 3fr 2fr; }
.steps { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
.btn { transition: none; }
}
</style>
</head>
<body>
<header class="site-header">
<nav class="container nav" aria-label="Main">
<a class="logo" href="#">Soko Fresh</a>
<ul>
<li><a href="#features">Why us</a></li>
<li><a href="#how">How it works</a></li>
<li><a href="#order">Order</a></li>
</ul>
</nav>
</header>
<main>
<section class="hero">
<div class="container hero-grid">
<div>
<h1>Fresh from the farm to your door</h1>
<p>Order sukuma wiki, tomatoes, avocados and more before 10 a.m. and get them delivered the same day anywhere in Nairobi.</p>
<a class="btn" href="#order">Start your order</a>
</div>
<div class="basket">
<h2>Today's basket</h2>
<ul>
<li>Sukuma wiki, 2 bunches</li>
<li>Tomatoes, 1 kg</li>
<li>Avocados, 4 pieces</li>
<li>Bananas, 1 dozen</li>
</ul>
<strong>KES 650, delivery included</strong>
</div>
</div>
</section>
<section id="features">
<div class="container">
<h2 class="section-title">Why Soko Fresh?</h2>
<div class="features">
<article class="feature">
<h3>Picked this morning</h3>
<p>We buy directly from farmers in Kiambu and Murang'a every day.</p>
</article>
<article class="feature">
<h3>Pay with M-Pesa</h3>
<p>Pay on delivery, after you have checked your order.</p>
</article>
<article class="feature">
<h3>Fair prices</h3>
<p>Market prices with no hidden fees, and free delivery over KES 1,500.</p>
</article>
</div>
</div>
</section>
<section id="how">
<div class="container">
<h2 class="section-title">How it works</h2>
<ol class="steps">
<li><div><h3>Choose</h3><p>Pick a ready basket or build your own.</p></div></li>
<li><div><h3>Order</h3><p>Send your order online or on WhatsApp before 10 a.m.</p></div></li>
<li><div><h3>Enjoy</h3><p>Receive it the same afternoon and pay on delivery.</p></div></li>
</ol>
</div>
</section>
<section id="order" class="cta">
<div class="container">
<h2>Ready for fresher meals?</h2>
<p>Ordering takes less than two minutes.</p>
<a class="btn" href="#">Order now</a>
</div>
</section>
</main>
<footer class="site-footer">
<div class="container">
<span>© 2026 Soko Fresh</span>
<span>Nairobi, Kenya</span>
</div>
</footer>
</body>
</html>
What you should see: a dark green header with "Soko Fresh" on the left and three white links on the right that turn amber on hover; it stays at the top as you scroll. The hero has a pale green gradient, a large dark green headline, a grey description and a round amber "Start your order" button that lifts slightly on hover. In a narrow preview the white basket card (with a soft shadow) sits below the text; at 48rem and wider it moves beside it. The three feature cards have a green stripe along the top and sit in a row when there's room, wrapping onto new lines when there isn't. "How it works" shows three steps numbered 1, 2 and 3 in green circles, stacked on phones and side by side on wider screens. A dark green call-to-action band and a dark navy footer finish the page.
Test like a real user: open the page on your own phone (save it as an .html file and open it, or publish it as described in Project: Personal Portfolio Page), use only the keyboard to reach every link, and switch your device to dark mode to see what still needs work.
Extend it
- Dark mode. Add a
@media (prefers-color-scheme: dark)block that redefines the custom properties (background, surface, ink, muted) so the whole page switches theme. You'll need to add a--bgvariable and use it onbody. - A pricing section. Add three basket sizes (small, family, office) as cards in a grid. Use
:has()or a.popularclass to highlight the middle one with a thicker border and a "Most popular" badge positioned withposition: absolute. - A mobile menu. On narrow screens, hide the links behind a "Menu" button. Style the open and closed states in CSS (using a class such as
.is-open), then toggle the class with a few lines of JavaScript (see Events), and animate the menu withtransformandopacity.
Key points
- Custom properties keep the whole theme in one place.
- Flexbox handles one-dimensional pieces (the header, each step); Grid handles the two-dimensional layout (hero, features, steps row).
- Mobile-first base styles plus one
min-widthquery cover phones to desktops. clamp()andauto-fitdo much of the responsive work without extra breakpoints.
Tip: use the ← and → keys to move between pages.
