Skip to content
Performance

Snap to half-pixels less often

Blurry edges on rotated blocks usually come from sub-pixel sizes.

Stacking order is the part that trips people up. In a flat layout, later elements paint on top. In a tilted scene, a block that is further back must paint first, even if it appears later in the markup. Either sort your markup by depth or give each block a z-index derived from its row and column.

Avoid this

Do not animate width or height on transformed blocks. Animate transform instead so the browser can skip layout.

Share

Written by

Theo Okafor

Theo writes about 3D transforms and rendering performance. He keeps a spreadsheet of every browser bug he has hit with preserve-3d.

All 18 posts by Theo Okafor

12 comments

  1. Alex Moreau

    Great write-up. Would love a follow-up on doing the same thing with SVG.

    Reply to Alex Moreau
    1. Theo OkaforAuthor

      Agreed, this is the part most tutorials skip.

      Reply to Theo Okafor
  2. Gus Lindgren

    The tip about naming faces instead of colours saved our design system a lot of pain.

    Reply to Gus Lindgren
    1. Nina Ahlberg

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

      Reply to Nina Ahlberg
    2. Kofi Mensah

      Glad it helped. The values are in the colour ratios reference.

      Reply to Kofi Mensah
  3. Chen Wei

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

    Reply to Chen Wei
  4. June Park

    Short and useful. More quick tips like this, please.

    Reply to June Park
    1. Ivo Petrov

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

      Reply to Ivo Petrov
  5. Farah Aziz

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

    Reply to Farah Aziz
  6. Soren Dahl

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

    Reply to Soren Dahl
  7. Lena Vogel

    Works nicely in Firefox. Safari needed the prefixed transform-style for us.

    Reply to Lena Vogel
  8. Tess Walsh

    Bookmarked. The table alone is worth it.

    Reply to Tess Walsh

Leave a comment

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