StoicBuilder

HandbookII the ForumCSS and layout

IIthe Forum, The shape of an app

CSS and layout

1 min readUpdated 28 November

In plain words

CSS sets how each part of a page looks, like colour, size and spacing, and layout rules such as flexbox and grid decide where each box sits.

Where you see it

In a Lovable project, the long className strings like "flex items-center gap-4 p-6" are Tailwind, a shorthand for CSS. Right-click any element, choose Inspect, and the Styles panel lists every rule touching it.

components/PostCard.tsxbrowser
<article className="flex gap-3 rounded-xl border p-4"> <img src={avatarUrl} alt="" className="h-10 w-10 shrink-0 rounded-full" /> <div className="min-w-0"> <p className="font-semibold">{author}</p> <p className="break-words text-gray-700">{text}</p> </div></article>
flex puts the avatar beside the text. min-w-0 and break-words stop a long post pushing the card off screen.

What goes wrong

  1. Only ever checking on a laptop

    A layout that looks fine 1440 pixels wide can overflow on a phone, with text running off the right edge. Check the mobile view in DevTools before you ship.

  2. Fixed pixel widths

    A card set to 600 pixels is wider than most phone screens. Use maximum widths and let things shrink.

    <div className="w-[600px]">
  3. Piling on !important

    When a style won't apply, the quick fix is !important, then another to beat the first. Ask why the rule is losing instead.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Check this page at 375, 768 and 1440 pixels wide and fix anything that overflows, overlaps or is too small to tap. Use the project's existing Tailwind classes and spacing, with no fixed widths and no !important.

Quick check

Sign in to earn +10 XP for it

On phones, Chirp posts containing long links stretch past the edge of the screen. What's causing it?

Got a prompt that touches CSS and layout?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.