Skip to content
CSS Transforms

Draw an isometric staircase in pure CSS

Stack blocks with custom properties and let the browser do the maths.

Motion adds a lot to isometric scenes, and it is also the fastest way to make someone feel unwell. Wrap every animation in a prefers-reduced-motion query. For readers who ask for less motion we keep the scene still and use a small colour change on hover instead, which keeps the interface responsive without any movement.

What you need

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

Where type fits in

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.

  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

Icons are the hardest isometric art to get right because there is so little room. At small sizes one of the three faces usually has to go, so we pick the two that best describe the object. A book keeps its cover and spine; a box keeps its top and front. Deciding early saves a lot of redrawing.

functions.phpPHP
 

[/tab][/tabs]

Colours used

Edges and highlights

Hover effects on isometric blocks work best when they follow the same rules as the static scene. Lift a block along its vertical axis, deepen its shadow on the floor, and leave the other blocks alone. Moving a block sideways, or changing its angle, breaks the projection and makes the scene feel unstable.

Workshops taught us more than any tutorial. Watching people fold paper cubes and then rebuild them in CSS showed exactly where the mental model breaks: the order of rotations, the origin of each face, and the moment a block turns inside out. Most of our tutorials now start with the paper version for that reason.

Accessibility for decorative art is mostly about getting out of the way. If an illustration adds no information, hide it from assistive technology with aria-hidden on its wrapper. If it does carry meaning, such as a chart, give it a text alternative that says what the picture shows, not how it was built.

What you built

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

6 comments

  1. Omar Haddad

    Any plans for a video version of this one?

    Reply to Omar Haddad
    1. Dana Ortiz

      Thanks! A follow-up is already in the drafts.

      Reply to Dana Ortiz
  2. Ivo Petrov

    Love the palette. Could you share the exact lightness values?

    Reply to Ivo Petrov
    1. Bea Kowalski

      Fixed now, thanks for spotting it.

      Reply to Bea Kowalski
  3. Chen Wei

    Is there a way to do the shadow without a pseudo-element? Our CMS strips empty spans.

    Reply to Chen Wei
  4. Gus Lindgren

    We used the grid background on our docs site and it looks great with a dark theme too.

    Reply to Gus Lindgren

Leave a comment

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