codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › CSS 3D transforms

CSS 3D transforms

Add depth.

Set perspective on the parent, then use rotateX, rotateY or translateZ on the child.

Example code

<style>
.s{perspective:400px;padding:30px}
.c{width:120px;height:80px;background:#e4572e;color:#fff;transform:rotateY(45deg);transition:transform .6s}
.c:hover{transform:rotateY(0)}
</style>
<div class='s'><div class='c'>Hover</div></div>

Run this code in the online editor

← CSS 2D transformsCSS tooltips →