TExcelTAD
Home › CSS › CSS Mini Project

CSS Mini Project: A Responsive Landing Page

In this project you'll build a complete landing page for an imaginary app called Plantly — a plant-watering reminder. You'll go step by step: base styles and variables, a navigation header, a hero section, feature cards, a pricing call-to-action and a footer, and finally make it all responsive. Every step is a playground you can edit; the last one contains the whole page.

What you'll use

Step Concepts
1. Foundation Box sizing, custom properties, fonts
2. Header Flexbox, links, hover states
3. Hero Gradients, clamp(), buttons
4. Features Grid with auto-fit, cards, shadows, transitions
5. Call to action & footer Centering, max-width
6. Responsive Media queries, mobile menu layout

Step 1 — Foundation

Start with a reset and a small set of CSS variables (custom properties) for colours and spacing. Changing a variable later restyles the whole page.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
  *, *::before, *::after { box-sizing: border-box; }
  :root {
    --green: #2e7d32;
    --green-light: #e8f5e9;
    --accent: #ffb300;
    --text: #1b2a1f;
    --radius: 12px;
    --space: 16px;
  }
  body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    line-height: 1.5;
  }
  .container { max-width: 960px; margin: 0 auto; padding: 0 var(--space); }
  .swatch { display: inline-block; width: 60px; height: 60px; border-radius: var(--radius); margin: 4px; }
</style>
</head>
<body>
  <div class="container">
    <h2>Plantly design tokens</h2>
    <span class="swatch" style="background: var(--green)"></span>
    <span class="swatch" style="background: var(--green-light)"></span>
    <span class="swatch" style="background: var(--accent)"></span>
    <span class="swatch" style="background: var(--text)"></span>
  </div>
</body>
</html>

Tip: .container with max-width + margin: 0 auto + side padding is the wrapper every section will reuse.

Step 2 — The header

The header is a Flexbox row: logo on the left, links in the middle area, a button on the right. justify-content: space-between spreads them out and align-items: center lines them up vertically.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<style>
  *, *::before, *::after { box-sizing: border-box; }
  :root { --green: #2e7d32; --green-light: #e8f5e9; --accent: #ffb300; --text: #1b2a1f; --radius: 12px; }
  body { margin: 0; font-family: system-ui, sans-serif; color: var(--text); }
  .container { max-width: 960px; margin: 0 auto; padding: 0 16px; }

  .site-header { background: white; border-bottom: 1px solid #e0e0e0; position: sticky; top: 0; }
  .site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
  .logo { font-weight: 800; font-size: 22px; color: var(--green); text-decoration: none; }
  .nav { display: flex; gap: 20px; list-style: none; margin: 0; padding: 0; }
  .nav a { color: var(--text); text-decoration: none; font-weight: 500; }
  .nav a:hover { color: var(--green); }
  .btn { display: inline-block; padding: 10px 18px; border-radius: 999px; background: var(--green); color: white; text-decoration: none; font-weight: 600; }
  .btn:hover { background: #1b5e20; }
</style>
</head>
<body>
  <header class="site-header">
    <div class="container">
      <a class="logo" href="#">🌱 Plantly</a>
      <ul class="nav">
        <li><a href="#features">Features</a></li>
        <li><a href="#pricing">Pricing</a></li>
        <li><a href="#faq">FAQ</a></li>
      </ul>
      <a class="btn" href="#">Get the app</a>
    </div>
  </header>
</body>
</html>

Step 3 — The hero

The hero is the big first impression: a gradient background, a large heading sized with clamp() so it scales with the screen, a sub-heading and two buttons. A Grid with two columns puts an illustration next to the text — here a "phone" drawn purely with CSS.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<style>
  *, *::before, *::after { box-sizing: border-box; }
  :root { --green: #2e7d32; --green-light: #e8f5e9; --accent: #ffb300; --text: #1b2a1f; --radius: 12px; }
  body { margin: 0; font-family: system-ui, sans-serif; color: var(--text); }
  .container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
  .btn { display: inline-block; padding: 12px 20px; border-radius: 999px; background: var(--green); color: white; text-decoration: none; font-weight: 600; }
  .btn.ghost { background: transparent; color: var(--green); border: 2px solid var(--green); }

  .hero { background: linear-gradient(135deg, var(--green-light), #fffde7); padding: 40px 0; }
  .hero .container { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: center; }
  .hero h1 { font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.1; margin: 0 0 12px; }
  .hero h1 span { color: var(--green); }
  .hero p { font-size: 1.1rem; margin: 0 0 20px; color: #4a5a4e; }
  .actions { display: flex; gap: 10px; flex-wrap: wrap; }
  .phone { justify-self: center; width: 130px; height: 220px; border-radius: 24px; background: #263238; padding: 10px; box-shadow: 0 16px 30px rgba(0,0,0,.25); }
  .screen { height: 100%; border-radius: 16px; background: linear-gradient(#a5d6a7, #66bb6a); display: grid; place-items: center; font-size: 56px; }
</style>
</head>
<body>
  <section class="hero">
    <div class="container">
      <div>
        <h1>Never forget to <span>water</span> again.</h1>
        <p>Plantly reminds you when each plant is thirsty.</p>
        <div class="actions"><a class="btn" href="#">Start free</a><a class="btn ghost" href="#">See how</a></div>
      </div>
      <div class="phone"><div class="screen">🪴</div></div>
    </div>
  </section>
</body>
</html>

Step 4 — Feature cards

Features use repeat(auto-fit, minmax(200px, 1fr)): three columns on wide screens, fewer as space shrinks — without a single media query. Each card lifts on hover with a transition.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<style>
  *, *::before, *::after { box-sizing: border-box; }
  :root { --green: #2e7d32; --green-light: #e8f5e9; --text: #1b2a1f; --radius: 12px; }
  body { margin: 0; font-family: system-ui, sans-serif; color: var(--text); }
  .container { max-width: 960px; margin: 0 auto; padding: 0 16px; }

  .features { padding: 32px 0; }
  .features h2 { text-align: center; margin: 0 0 20px; }
  .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
  .card {
    background: white; border: 1px solid #e0e0e0; border-radius: var(--radius); padding: 20px;
    transition: transform .2s ease, box-shadow .2s ease;
  }
  .card:hover { transform: translateY(-4px); box-shadow: 0 10px 20px rgba(46,125,50,.15); }
  .icon { width: 48px; height: 48px; border-radius: 50%; background: var(--green-light); display: grid; place-items: center; font-size: 24px; margin-bottom: 10px; }
  .card h3 { margin: 0 0 6px; }
  .card p { margin: 0; color: #5f6b62; }
</style>
</head>
<body>
  <section class="features" id="features">
    <div class="container">
      <h2>Why Plantly?</h2>
      <div class="cards">
        <article class="card"><div class="icon">💧</div><h3>Smart reminders</h3><p>Schedules adapt to season and pot size.</p></article>
        <article class="card"><div class="icon">📷</div><h3>Plant ID</h3><p>Snap a leaf to learn what you're growing.</p></article>
        <article class="card"><div class="icon">📈</div><h3>Growth log</h3><p>Track new leaves and repotting dates.</p></article>
      </div>
    </div>
  </section>
</body>
</html>

Step 5 — Call to action and footer

A centred call-to-action band with a dark background, followed by a footer whose columns use Flexbox with wrapping.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<style>
  *, *::before, *::after { box-sizing: border-box; }
  :root { --green: #2e7d32; --accent: #ffb300; --text: #1b2a1f; }
  body { margin: 0; font-family: system-ui, sans-serif; color: var(--text); }
  .container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
  .btn { display: inline-block; padding: 12px 22px; border-radius: 999px; text-decoration: none; font-weight: 700; }

  .cta { background: var(--green); color: white; text-align: center; padding: 36px 0; }
  .cta h2 { margin: 0 0 8px; }
  .cta p { margin: 0 auto 18px; max-width: 40ch; opacity: .9; }
  .cta .btn { background: var(--accent); color: var(--text); }
  .cta .btn:hover { filter: brightness(1.08); }

  .site-footer { background: #1b2a1f; color: #c8d3ca; padding: 24px 0; font-size: 14px; }
  .site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
  .site-footer a { color: #c8d3ca; text-decoration: none; margin-right: 14px; }
  .site-footer a:hover { color: white; }
</style>
</head>
<body>
  <section class="cta" id="pricing">
    <div class="container">
      <h2>Free for your first 10 plants</h2>
      <p>Upgrade to Plantly Pro for unlimited plants and family sharing.</p>
      <a class="btn" href="#">Download now</a>
    </div>
  </section>
  <footer class="site-footer">
    <div class="container">
      <span>© Plantly — grown with CSS</span>
      <nav><a href="#">Privacy</a><a href="#">Terms</a><a href="#">Contact</a></nav>
    </div>
  </footer>
</body>
</html>

Step 6 — Putting it together and going responsive

Now combine all sections and add media queries for small screens. Under 600px:

  • The header nav is hidden behind a simpler layout (logo + button only) — in a real site a hamburger menu would toggle it.
  • The hero's two columns become one, with the phone underneath.
  • Padding shrinks a little.

The feature grid already adapts on its own. Drag the playground's edge to below 600px and watch the layout change.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
  *, *::before, *::after { box-sizing: border-box; }
  :root { --green: #2e7d32; --green-light: #e8f5e9; --accent: #ffb300; --text: #1b2a1f; --radius: 12px; --pad: 40px; }
  body { margin: 0; font-family: system-ui, sans-serif; color: var(--text); line-height: 1.5; }
  .container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
  .btn { display: inline-block; padding: 10px 18px; border-radius: 999px; background: var(--green); color: white; text-decoration: none; font-weight: 600; }
  .btn.ghost { background: transparent; color: var(--green); border: 2px solid var(--green); }

  /* Header */
  .site-header { background: white; border-bottom: 1px solid #e0e0e0; position: sticky; top: 0; z-index: 10; }
  .site-header .container { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
  .logo { font-weight: 800; font-size: 20px; color: var(--green); text-decoration: none; }
  .nav { display: flex; gap: 18px; list-style: none; margin: 0; padding: 0; }
  .nav a { color: var(--text); text-decoration: none; }
  .nav a:hover { color: var(--green); }

  /* Hero */
  .hero { background: linear-gradient(135deg, var(--green-light), #fffde7); padding: var(--pad) 0; }
  .hero .container { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: center; }
  .hero h1 { font-size: clamp(1.7rem, 5vw, 3rem); line-height: 1.1; margin: 0 0 12px; }
  .hero h1 span { color: var(--green); }
  .hero p { margin: 0 0 18px; color: #4a5a4e; }
  .actions { display: flex; gap: 10px; flex-wrap: wrap; }
  .phone { justify-self: center; width: 120px; height: 200px; border-radius: 22px; background: #263238; padding: 9px; box-shadow: 0 14px 28px rgba(0,0,0,.25); }
  .screen { height: 100%; border-radius: 14px; background: linear-gradient(#a5d6a7, #66bb6a); display: grid; place-items: center; font-size: 50px; }

  /* Features */
  .features { padding: var(--pad) 0; }
  .features h2 { text-align: center; margin: 0 0 18px; }
  .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
  .card { border: 1px solid #e0e0e0; border-radius: var(--radius); padding: 18px; transition: transform .2s, box-shadow .2s; }
  .card:hover { transform: translateY(-4px); box-shadow: 0 10px 20px rgba(46,125,50,.15); }
  .icon { width: 44px; height: 44px; border-radius: 50%; background: var(--green-light); display: grid; place-items: center; font-size: 22px; margin-bottom: 8px; }
  .card h3 { margin: 0 0 4px; }
  .card p { margin: 0; color: #5f6b62; }

  /* CTA + footer */
  .cta { background: var(--green); color: white; text-align: center; padding: var(--pad) 0; }
  .cta h2 { margin: 0 0 8px; }
  .cta p { margin: 0 auto 16px; max-width: 40ch; }
  .cta .btn { background: var(--accent); color: var(--text); }
  .site-footer { background: #1b2a1f; color: #c8d3ca; padding: 20px 0; font-size: 14px; }
  .site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
  .site-footer a { color: #c8d3ca; text-decoration: none; margin-right: 12px; }

  /* Responsive */
  @media (max-width: 600px) {
    :root { --pad: 24px; }
    .nav { display: none; }
    .hero .container { grid-template-columns: 1fr; text-align: center; }
    .actions { justify-content: center; }
    .site-footer .container { flex-direction: column; align-items: center; }
  }
</style>
</head>
<body>
  <header class="site-header">
    <div class="container">
      <a class="logo" href="#">🌱 Plantly</a>
      <ul class="nav"><li><a href="#features">Features</a></li><li><a href="#pricing">Pricing</a></li><li><a href="#faq">FAQ</a></li></ul>
      <a class="btn" href="#">Get the app</a>
    </div>
  </header>

  <section class="hero">
    <div class="container">
      <div>
        <h1>Never forget to <span>water</span> again.</h1>
        <p>Plantly reminds you when each plant is thirsty.</p>
        <div class="actions"><a class="btn" href="#">Start free</a><a class="btn ghost" href="#">See how</a></div>
      </div>
      <div class="phone"><div class="screen">🪴</div></div>
    </div>
  </section>

  <section class="features" id="features">
    <div class="container">
      <h2>Why Plantly?</h2>
      <div class="cards">
        <article class="card"><div class="icon">💧</div><h3>Smart reminders</h3><p>Schedules adapt to season and pot size.</p></article>
        <article class="card"><div class="icon">📷</div><h3>Plant ID</h3><p>Snap a leaf to learn what you're growing.</p></article>
        <article class="card"><div class="icon">📈</div><h3>Growth log</h3><p>Track new leaves and repotting dates.</p></article>
      </div>
    </div>
  </section>

  <section class="cta" id="pricing">
    <div class="container">
      <h2>Free for your first 10 plants</h2>
      <p>Upgrade to Plantly Pro for unlimited plants and family sharing.</p>
      <a class="btn" href="#">Download now</a>
    </div>
  </section>

  <footer class="site-footer">
    <div class="container">
      <span>© Plantly — grown with CSS</span>
      <nav><a href="#">Privacy</a><a href="#">Terms</a><a href="#">Contact</a></nav>
    </div>
  </footer>
</body>
</html>

Note: Notice how one variable, --pad, is redefined inside the media query and every section's spacing updates at once. That's the power of custom properties combined with media queries.

Ideas to extend it

  • Add a dark theme by redefining the variables inside @media (prefers-color-scheme: dark).
  • Build a hamburger toggle for the hidden nav with a checkbox and the :checked pseudo-class.
  • Add a FAQ section using <details> elements styled with ::marker and transitions.
  • Animate the phone gently floating up and down with @keyframes.

Test yourself

Why does the feature grid adapt to narrow screens without a media query?

  1. Because of flex-wrap
  2. Because repeat(auto-fit, minmax(200px, 1fr)) creates only as many columns as fit
  3. Because cards have max-width
  4. It doesn't adapt

What does redefining --pad inside the media query achieve?

  1. Nothing, variables can't change
  2. Every rule using var(--pad) gets the new value on small screens
  3. It only affects :root's own padding
  4. It creates a new property called pad

How does the hero switch to a single column on small screens?

  1. display: none on the phone
  2. grid-template-columns: 1fr in the media query
  3. float: none
  4. flex-direction: row