Skip to content
CSS Transforms

Quick tip: use aspect-ratio for cube faces

One property keeps every face square, whatever its width.

Grids are the backbone of every scene we draw. A single grid unit decides tile width, block height and spacing, which is why our illustrations line up even when three different people made them. When something looks off, the first thing we check is whether one element quietly ignored the grid.

Pro tip

Hold Shift while dragging in the Layers panel to rotate the 3D view and spot faces that are drawn in the wrong order.

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

Written by

Inês Duarte

Inês is Cubefold's colour and type lead. She believes every isometric scene needs exactly one warm accent, and not two.

All 16 posts by Inês Duarte

12 comments

  1. Farah Aziz

    This is the clearest explanation of draw order I have read.

    Reply to Farah Aziz
  2. Rosa Medina

    How would you handle text that needs to wrap on one of the faces?

    Reply to Rosa Medina
  3. Chen Wei

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

    Reply to Chen Wei
  4. June Park

    The part about layer counts was eye-opening. Our landing page had over a hundred.

    Reply to June Park
    1. Inês DuarteAuthor

      Fixed now, thanks for spotting it.

      Reply to Inês Duarte
    2. Dana Ortiz

      Good question. Usually that means something is flattening the 3D context; check for overflow hidden on a parent.

      Reply to Dana Ortiz
  5. Pia Jensen

    The paper cube exercise sounds fun. Are the templates available somewhere?

    Reply to Pia Jensen
    1. Tess Walsh

      The templates are in the downloads section of the reference post.

      Reply to Tess Walsh
  6. Mateo Rossi

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

    Reply to Mateo Rossi
  7. Kofi Mensah

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

    Reply to Kofi Mensah
  8. Lena Vogel

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

    Reply to Lena Vogel
    1. Inês DuarteAuthor

      Agreed, this is the part most tutorials skip.

      Reply to Inês Duarte

Leave a comment

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