Twisting puzzle cube
Pure CSSA 3×3×3 cube built as three layers that take turns twisting a quarter turn. Each layer is one flat box with the stickers painted on by gradients.
Isometric plates lifting apart along the Z axis, each driven by one custom property.
Your edited version
rotateX(58deg) rotateZ(-45deg) on the parent gives the classic isometric viewing angle.translateZ separates them.--i, and the keyframe uses calc(var(--i) * 40px) — one animation, four different results.rotateX + rotateZ isometric viewtranslateZvar() inside @keyframes<div class="scene">
<div class="layers">
<i style="--i:0"></i>
<i style="--i:1"></i>
<i style="--i:2"></i>
<i style="--i:3"></i>
</div>
</div>
.scene {
perspective: 900px;
}
.layers {
position: relative;
width: 140px;
height: 140px;
transform-style: preserve-3d;
transform: rotateX(58deg) rotateZ(-45deg);
}
.layers i {
position: absolute;
inset: 0;
border-radius: 16px;
border: 1px solid rgb(255 255 255 / 0.35);
background: hsl(calc(255 + var(--i) * 32) 85% 62% / 0.78);
animation: lift 2.6s ease-in-out infinite alternate;
}
@keyframes lift {
to { transform: translateZ(calc(var(--i) * 40px)); }
}
.d-layers {
position: relative;
width: 120px;
height: 120px;
transform-style: preserve-3d;
transform: translateY(24px) rotateX(58deg) rotateZ(-45deg);
i {
position: absolute;
inset: 0;
border-radius: 16px;
border: 1px solid rgb(255 255 255 / 0.35);
// --i (0…3) comes from the markup; it drives both colour and lift.
background: hsl(calc(255 + var(--i) * 32) 85% 62% / 0.78);
animation: d-layers-lift 2.6s ease-in-out infinite alternate;
}
}
@keyframes d-layers-lift {
to {
transform: translateZ(calc(var(--i) * 38px));
}
}