M4RKYU.SYSEdition 2027
Skip to content
LOCZH/安大略 · 加拿大/▸logs · quick guide to 3d transformations in css3 2ki5待机OK/--:--:--EST
M4M4RK_YUportfolio
  • 创作创作
    创作Overview
    • 作品精选案例与项目记录
    • 游戏可玩原型与游戏开发日志
  • 影像影像
    影像Overview
    • 照片影像合集与视觉实验
    • 商店印刷品、海报和限量物件
  • 写作写作
    写作Overview
    • 博客长篇开发日志与现场笔记
    • 笔记短观察、链接与代码片段
  • 资源资源
    资源Overview
    • 工具38 款浏览器内开发工具
    • 链接每日使用的开发与设计书签
  • 关于关于
  • 联系联系
EN

同步 · dev.to / @markyu

CSS 3D Transform Bugs Usually Come From Perspective

A practical CSS 3D transform guide explaining perspective, rotateX, rotateY, transform-style, backface visibility, and debugging layout.

发布日期
May 20 '24
·
阅读时长
2 min read
·
点赞
4
cssfrontendwebdevanimation
在 dev.to 查看

本页目录

  • Start With a Card
  • The Three Properties That Matter
  • Rotate X vs Rotate Y
  • Common Mistake: Perspective on the Wrong Element
  • Final Thought

CSS 3D transforms look broken when one property is missing: perspective.

Without perspective, your element can rotate in 3D but still feel flat or strange. The browser is doing math; your eyes are just not getting depth cues.

Start With a Card

<div class="scene">
  <div class="card">
    <div class="face front">Front</div>
    <div class="face back">Back</div>
  </div>
</div>
.scene {
  width: 240px;
  height: 320px;
  perspective: 900px;
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 600ms ease;
}

.scene:hover .card {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  backface-visibility: hidden;
}

.front {
  background: #2563eb;
  color: white;
}

.back {
  background: #111827;
  color: white;
  transform: rotateY(180deg);
}

That is a real 3D card flip.

The Three Properties That Matter

PropertyJob
perspectivegives depth to children
transform-style: preserve-3dkeeps child elements in 3D space
backface-visibility: hiddenhides the mirrored backside

If your card shows mirrored text, check backface-visibility.

If the back face never appears, check the rotateY(180deg) on the back.

If everything looks flat, check perspective.

Rotate X vs Rotate Y

transform: rotateX(45deg);

Rotates around the horizontal axis.

transform: rotateY(45deg);

Rotates around the vertical axis.

transform: rotateZ(45deg);

This is the normal 2D-style rotation most developers already know.

Common Mistake: Perspective on the Wrong Element

This is usually wrong:

.card {
  perspective: 900px;
  transform: rotateY(180deg);
}

Perspective should usually be on the parent:

.scene {
  perspective: 900px;
}

The parent creates the viewing space. The child moves inside it.

Final Thought

CSS 3D is not hard, but it is unforgiving. One missing property can make the whole demo feel fake.

What 3D UI effect do you actually like in production apps: card flips, subtle tilt, or none at all?

相关阅读

CSS Heart Animation: Small Demo, Real Animation Lessons

A cleaner CSS heart animation tutorial focused on transform, pseudo-elements, keyframes, and the small mistakes that break simple UI animations.

css

React 19 Micro-Interactions Without Layout Jank

A practical React 19 micro-interactions guide focused on motion boundaries, CSS transitions, optimistic UI, reduced motion, and performance.

react

Next.js Images Without CLS: My LQIP Blur-Up Setup

A practical Next.js image optimization guide for zero CLS layouts, blur placeholders, dimensions, remote images, and production image hygiene.

nextjs

原文发布

本文首发于 dev.to,评论与点赞保留在原站。

在 dev.to 继续阅读
上一篇Cloud Architecture Choices I Would Not OvercomplicateA practical 2026 cloud architecture guide for developers choosing between client-server, distributed systems, microservices, serverless, and cloud-native platforms.
返回全部文章
下一篇Debug a Slow MySQL Query Before You Guess at IndexesA practical MySQL workflow for finding slow queries, reading EXPLAIN output, and deciding whether an index actually helps.
返回档案
M4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYU
始于 2024
ZhenXiao Mark YuZhenXiao Mark Yu
联系

看到什么有意思的?和我聊聊。

这是一个作品集,不是服务 · 但每一条留言我都会看 — 如果哪里让你有所触动,或者只想打个招呼,欢迎写信过来。

开启对话
频道开放

随时打个招呼 · 2026

--:--:--EST加拿大 安大略
  • 邮件
  • GitHub
  • dev.to
  • 领英
  • 推特 / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat

订阅

偶尔收到一封简讯

来自 m4rkyu.com 的笔记与日志——简短、标注日期、没有杂音。随时可退订。

作品

线上发布、游戏作品与视觉档案。

  • 项目
  • 游戏
  • 档案
  • 日志

资源

每日好用的工具与个人收藏的链接库。

  • 搜索
  • 最新
  • 工具
  • 链接
  • 笔记
  • 主题
  • 商店
RSSJSON Feed

工作室

背景、联系方式以及合作渠道。

  • 关于
  • 联系
  • 更新日志
  • 技术说明
  • 简历筹备中

社交

在常去的平台上找到我。

  • GitHub
  • dev.to
  • 领英
  • 推特 / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
  • 邮件
© 2026 ZhenXiao Mark Yumarkyu0615@gmail.com
  • 邮件
  • GitHub
  • dev.to
  • 领英
  • 推特 / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
隐私条款由 Next.js 16 · React 19 · Tailwind 4 构建