Design Technologist · AI-Assisted CSS Engineering

Flexbox Interfaces, from document flow to an audited commerce layout.

This showcase documents the complete assignment from raw semantic HTML through prompt engineering, human auditing, and a verified responsive header and checkout experience.

01Problem
02CSS Concepts
03Raw HTML
04AI Prompt
05Audit
06Final Result
07Verification
01

Why normal document flow was not enough

Commerce interfaces require deliberate alignment, distribution, wrapping, and direction-aware spacing.

Before

Ordinary block elements stack vertically. They do not automatically center navigation content, separate a logo from actions, align product rows, or hold a checkout form beside an order summary. Physical left and right spacing also becomes fragile when writing direction changes.

Modern approach

Flexbox controls one-dimensional alignment and distribution while Logical Properties express spacing through block and inline directions. The AI can draft the system, but a developer must still remove floats, child margins, brittle widths, and overflow-prone assumptions.

Floats Physical margins Missing border-box Fixed widths Colliding controls
02

The CSS systems behind dependable interface alignment

Six coordinated ideas turn raw structure into resilient application components.

03

The semantic HTML before layout engineering

The content is meaningful and complete, but the browser has not been given an interface system yet.

before.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Week 3 Lab: Flexbox Interfaces</title>
</head>
<body>

  <!-- COMPONENT 1: MULTI-TIER HEADER -->
  <header class="site-header">
    <!-- Top Utility Bar -->
    <div class="header__utility">
      <span class="utility__promo">Free shipping on orders over $50!</span>
      <nav class="utility__nav">
        <a href="#support">Support</a>
        <a href="#stores">Find a Store</a>
      </nav>
    </div>

    <!-- Main Navigation Bar -->
    <div class="header__main">
      <div class="header__logo">StyleStore</div>
      <nav class="header__nav">
        <ul class="nav__list">
          <li><a href="#new">New Arrivals</a></li>
          <li><a href="#shop">Shop All</a></li>
          <li><a href="#sale">Sale</a></li>
        </ul>
      </nav>
      <div class="header__actions">
        <button class="btn-icon">🔍</button>
        <button class="btn-icon">🛒 <span class="cart-count">2</span></button>
      </div>
    </div>
  </header>

  <!-- COMPONENT 2: CHECKOUT PAGE WRAPPER -->
  <div class="checkout-container">
    <main class="checkout-form-placeholder">
      <h2>Shipping Details</h2>
      <p>Imagine your interactive shipping form inputs living right here...</p>
    </main>

    <!-- The Checkout Sidebar Summary List -->
    <aside class="checkout-summary">
      <h3 class="summary__title">Order Summary</h3>

      <ul class="summary__items">
        <li class="summary-item">
          <img
            src="https://images.unsplash.com/photo-1523381210434-271e8be1f52b?w=100"
            alt="Minimalist T-Shirt"
            class="summary-item__img"
          >
          <div class="summary-item__details">
            <span class="summary-item__name">Classic Crewneck T-Shirt</span>
            <span class="summary-item__qty">Qty: 1</span>
          </div>
          <span class="summary-item__price">$28.00</span>
        </li>

        <li class="summary-item">
          <img
            src="https://images.unsplash.com/photo-1542291026-7eec264c27ff?w=100"
            alt="Red Sneakers"
            class="summary-item__img"
          >
          <div class="summary-item__details">
            <span class="summary-item__name">Retro Runners</span>
            <span class="summary-item__qty">Qty: 1</span>
          </div>
          <span class="summary-item__price">$85.00</span>
        </li>
      </ul>

      <div class="summary__totals">
        <div class="totals-line">
          <span>Subtotal</span>
          <span>$113.00</span>
        </div>

        <div class="totals-line">
          <span>Shipping</span>
          <span>FREE</span>
        </div>

        <div class="totals-line totals-line--grand">
          <span>Total</span>
          <span>$113.00</span>
        </div>
      </div>
    </aside>
  </div>

</body>
</html>

Browser defaults only

Shipping Details

Form content appears in normal document flow.

04

How the AI prompt became an auditable contract

Each layer specifies a behavior that can be inspected instead of asking the model to simply “make it look good.”

Layer 1 — Lock the structure

Preserve the supplied semantic elements and structural class names.

Layer 2 — Stabilize sizing

Require a scoped border-box reset and predictable custom-property tokens.

Layer 3 — Assign Flexbox roles

Define which parents align, distribute, wrap, and grow their children.

Layer 4 — Require logical spacing

Ban physical margin and padding declarations from the generated stylesheet.

Layer 5 — Prefer intrinsic response

Use wrapping, flexible basis values, and min-inline-size instead of breakpoint patches.

Layer 6 — Demand verification

Include focus, zoom, reduced-motion, print, overflow, and RTL checks.

AI prompt
Act as a senior CSS systems engineer. Generate a production-ready stylesheet for the supplied Flexbox interface HTML without replacing its structural class system.

Architecture requirements:

1. Apply a predictable box-model reset. Use box-sizing: border-box on all elements and pseudo-elements. Reset default margins and padding deliberately without using html { font-size: 62.5%; }.

2. Style .header__utility and .header__main with display: flex, align-items: center, justify-content: space-between, flex-wrap: wrap, and parent-controlled gap values.

3. Style .utility__nav, .nav__list, and .header__actions as Flexbox groups. Remove the list markers and default list spacing from .nav__list.

4. Do not add directional margins to individual navigation links or action buttons. Use gap on the appropriate parent Flexbox container.

5. Build the checkout area with Flexbox. The form region and order-summary sidebar must appear side by side when enough inline space exists and stack naturally on smaller viewports.

6. Prefer intrinsic responsiveness using flex-wrap, flex-basis, min(), max(), clamp(), and min-inline-size: 0. Use no more than one targeted media query if intrinsic wrapping cannot fully satisfy the layout.

7. Use CSS Logical Properties for all spacing and sizing adjustments. Use padding-block, padding-inline, margin-block, margin-inline, margin-block-end, border-inline-start, inline-size, min-inline-size, and max-inline-size instead of physical top, right, bottom, and left properties.

8. Physical margin and padding declarations such as margin-left, margin-right, margin-top, margin-bottom, padding-left, padding-right, padding-top, and padding-bottom are prohibited.

9. Style each .summary-item as a Flexbox row. Vertically align the image, product details, and price. Allow the details region to grow while keeping the price readable and aligned.

10. Give product images a controlled logical size, aspect-ratio, object-fit: cover, and flex-shrink: 0.

11. Style .summary__totals as a vertical Flexbox group and each .totals-line as a horizontal Flexbox row using justify-content: space-between.

12. Use CSS Custom Properties for colors, spacing, borders, radii, shadows, layout widths, and transitions.

13. Use a modern, accessible e-commerce visual theme with readable contrast, visible keyboard focus states, minimum practical button target sizes, and clear hover states.

14. Ensure long navigation labels and product names can wrap without breaking the layout. Apply min-inline-size: 0 and overflow-wrap where needed.

15. Do not use floats, absolute positioning for the main layout, CSS tables, or Grid to construct the assignment’s header and checkout components. Flexbox must perform the primary layout work.

16. Add concise comments explaining the global box model, parent gap strategy, intrinsic checkout wrapping, and Logical Property choices.

17. Include reduced-motion handling and sensible print styles.

Return only the complete CSS stylesheet.
05

Auditing the generated Flexbox system

The draft only becomes trustworthy after its layout mechanics and direction-aware spacing are inspected.

audited CSS excerpt
*,
*::before,
*::after {
  box-sizing: border-box;
}

.header__utility,
.header__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-m);
  padding-block: var(--space-s);
  padding-inline: var(--space-l);
}

.nav__list,
.header__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-m);
}

.checkout-container {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-xl);
}

.checkout-form-placeholder {
  flex: 1 1 32rem;
  min-inline-size: 0;
}

.checkout-summary {
  flex: 1 1 20rem;
  max-inline-size: 26rem;
  padding-block: var(--space-l);
  padding-inline: var(--space-l);
}

.summary-item,
.totals-line {
  display: flex;
  align-items: center;
  gap: var(--space-m);
}

.summary-item__details {
  flex: 1 1 auto;
  min-inline-size: 0;
}
spacing correction
/* Avoid: physical, child-owned spacing */
.nav__list a {
  margin-right: 1rem;
  padding-left: 2rem;
}

/* Prefer: logical, parent-owned spacing */
.nav__list {
  display: flex;
  gap: 1rem;
  padding-inline-start: 2rem;
}
Verified: global border-box

Padding and borders remain inside declared component sizes.

Verified: Flexbox alignment

The header tiers and commerce rows use explicit main- and cross-axis rules.

Verified: parent gap

Navigation links, actions, products, and totals are spaced by their parent containers.

Verified: Logical Properties

Block and inline spacing replaces fixed top, right, bottom, and left assumptions.

Corrected: no float-based layout

Flexible growth and wrapping replace brittle float and absolute-position techniques.

Corrected: shrink-safe children

min-inline-size: 0 allows long product names and navigation labels to wrap.

Verified: intrinsic checkout wrap

The form and summary stack as available inline space decreases.

Verified: visible focus

Keyboard users receive strong focus indicators on every interactive control.

06

The final header and checkout after the audit

Resize or zoom the page: major groups wrap, product details shrink safely, and the sidebar stacks without horizontal overflow.

Checkout · Step 1 of 2

Shipping Details

Enter the destination information for this order.

One alignment engine

Flexbox controls each header tier, navigation group, product row, total row, and checkout column.

One spacing language

gap, padding-inline, and margin-block keep ownership clear.

Intrinsic before breakpoint

Flexible basis values and wrapping do most of the responsive work before one targeted query.

Direction-aware spacing

Logical properties follow the language.

padding-inline, margin-block-end, and border-inline-start express intent without hard-coding left or right.

LTRStart edge
RTLStart edge
07

Technical verification before deployment

The final interface is accepted only after its computed behavior is tested.

  1. Inspect both header tiers and confirm their computed display value is flex.
  2. Confirm centering, space distribution, wrapping, and parent gap are active.
  3. Resize continuously and verify navigation groups wrap rather than collide.
  4. Confirm the checkout columns sit side by side when space allows and stack when constrained.
  5. Search the stylesheet for prohibited physical margin and padding declarations.
  6. Verify spacing between flex children is controlled by the parent container.
  7. Inspect computed sizing and confirm the scoped border-box reset.
  8. Confirm card padding does not swell components beyond their intended inline size.
  9. Navigate with the keyboard and verify visible focus on every link and button.
  10. Zoom to 200% and confirm text, controls, and product rows remain usable.
  11. Apply dir="rtl" temporarily and confirm logical spacing mirrors correctly.
  12. Test near 320px and confirm there is no unintended horizontal page scrolling.
  13. Use the Accessibility panel or Lighthouse to inspect landmarks, names, alt text, and contrast.

AI drafted the CSS. Human auditing verified maintainability, accessibility, and standards compliance.