Skip to content
Grid Systems

Lay out an isometric room with CSS grid

Walls, floor and furniture placed on a single tilted grid.

Three colours carry the whole illusion. The top face is the lightest because it faces the sky, the left face sits in the middle, and the right face is the darkest. Keep those three roles consistent across the page and readers stop seeing flat shapes. Break the rule once, with a dark top on a single block, and the entire scene looks wrong.

What you need

A code editor, a modern browser and about twenty minutes. No libraries or build step.

Start with the floor

Testing on real devices matters for 3D transforms. Emulators get the layout right but not always the rendering, and older phones sometimes draw faces in the wrong order or with visible seams. We keep a drawer of old handsets for exactly this reason, and every tutorial gets a quick check on each of them.

  1. Draw the floor

    Create a wrapper with transform: rotateX(60deg) rotateZ(-45deg). This tilts the whole scene into isometric space.

  2. Place a cube

    Add a square child and give it three faces with pseudo-elements. Each face gets one of the three shading colours.

  3. Lift it on hover

    Translate the cube along its Z axis on hover and deepen the floor shadow at the same time.

The code

Reading isometric art is a learned skill, and most readers have learned it from games and instruction manuals. That shared vocabulary is what makes the style so friendly. It also means readers notice immediately when something is off, even if they cannot say why, so consistency matters more than detail.

motion.cssCSS
@media (prefers-reduced-motion: no-preference) {	.cube:hover {		transform: translateZ(calc(var(--unit) / 2));		transition: transform 180ms ease-out;	}}

<div class="scene" aria-hidden="true">	<div class="cube"></div></div>

Colours used

Shadows that sell the weight

The classic CSS recipe is rotateX(60deg) followed by rotateZ(-45deg). The first rotation tips the square away from you; the second turns it so its corners point up and down. Together they give the familiar diamond. Swap the order and you get something else entirely, because transforms apply from right to left, which catches almost everyone at least once.

What you built

  • A cube with three shaded faces
  • A floor grid from gradients
  • A hover state that lifts the block
Share

5 comments

  1. Chen Wei

    I teach an intro CSS class and I am going to use this as the final project.

    Reply to Chen Wei
  2. Tess Walsh

    Bookmarked. The table alone is worth it.

    Reply to Tess Walsh
  3. June Park

    Any plans for a video version of this one?

    Reply to June Park
    1. Soren Dahl

      Yes, container queries work well; we will cover them soon.

      Reply to Soren Dahl
  4. Dana Ortiz

    Tiny typo in the second code block: the unit is missing on the translate value.

    Reply to Dana Ortiz

Leave a comment

Your email address won’t be published. Required fields are marked.