2D and 3D transforms - tilts, cubes, perspective and chained motion - driven only by hover and keyframes.
13D Rotating Cube
A spinning six-sided cube; give the element six children for the faces and set --fx-size if needed. Class: fx-3d-rotating-cube
<div class="d-flex flex-wrap align-items-center justify-content-center gap-3 p-3 h-100" style="min-height:200px">
<div class="fx-3d-rotating-cube" aria-hidden="true">
<div>
<i class="bi bi-box" aria-hidden="true"></i>
</div>
<div>
<i class="bi bi-gem" aria-hidden="true"></i>
</div>
<div>
<i class="bi bi-star-fill" aria-hidden="true"></i>
</div>
<div>
<i class="bi bi-heart-fill" aria-hidden="true"></i>
</div>
<div>
<i class="bi bi-trophy-fill" aria-hidden="true"></i>
</div>
<div>
<i class="bi bi-bell-fill" aria-hidden="true"></i>
</div>
</div>
</div>
/* CSS (already in assets/css/effects.css) */
.fx-3d-rotating-cube {
--fx-half: calc(var(--fx-size, 6rem) / 2);
position: relative; width: var(--fx-size, 6rem); height: var(--fx-size, 6rem);
transform-style: preserve-3d;
animation: fx-3d-rotating-cube-spin 12s linear infinite;
}
.fx-3d-rotating-cube:hover { animation-play-state: paused; }
.fx-3d-rotating-cube > * {
position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.6rem;
color: var(--wt-on-primary, #fff); border: 1px solid rgba(255, 255, 255, .35);
background: rgba(var(--wt-primary-rgb), .88);
}
.fx-3d-rotating-cube > :nth-child(1) { transform: translateZ(var(--fx-half)); }
.fx-3d-rotating-cube > :nth-child(2) { transform: rotateY(180deg) translateZ(var(--fx-half)); background: rgba(var(--wt-secondary-rgb), .88); }
.fx-3d-rotating-cube > :nth-child(3) { transform: rotateY(90deg) translateZ(var(--fx-half)); background: rgba(var(--wt-accent-rgb), .88); }
.fx-3d-rotating-cube > :nth-child(4) { transform: rotateY(-90deg) translateZ(var(--fx-half)); background: rgba(var(--wt-secondary-rgb), .88); }
.fx-3d-rotating-cube > :nth-child(5) { transform: rotateX(90deg) translateZ(var(--fx-half)); background: rgba(var(--wt-accent-rgb), .88); }
.fx-3d-rotating-cube > :nth-child(6) { transform: rotateX(-90deg) translateZ(var(--fx-half)); }
@keyframes fx-3d-rotating-cube-spin {
from { transform: perspective(700px) rotateX(-22deg) rotateY(0deg); }
to { transform: perspective(700px) rotateX(-22deg) rotateY(360deg); }
}
@media (prefers-reduced-motion: reduce) {
.fx-3d-rotating-cube, .fx-3d-rotating-cube::before, .fx-3d-rotating-cube::after, .fx-3d-rotating-cube *, .fx-3d-rotating-cube *::before, .fx-3d-rotating-cube *::after { animation: none !important; transition: none !important; }
}2Perspective Text
Lays a heading back in 3D perspective with depth layers; it stands up straight on hover. Class: fx-perspective-text
Next level
<div class="d-flex flex-wrap align-items-center justify-content-center gap-3 p-3 h-100" style="min-height:200px">
<h2 class="display-5 fw-bold text-uppercase mb-0 fx-perspective-text">Next level</h2>
</div>
/* CSS (already in assets/css/effects.css) */
.fx-perspective-text {
display: inline-block; transform: perspective(500px) rotateX(28deg); transform-origin: 50% 100%;
text-shadow: 0 1px 0 rgba(var(--wt-primary-rgb), .6), 0 2px 0 rgba(var(--wt-primary-rgb), .5), 0 3px 0 rgba(var(--wt-primary-rgb), .4), 0 10px 14px rgba(0, 0, 0, .25);
transition: transform .6s cubic-bezier(.2, .8, .2, 1);
}
.fx-perspective-text:hover { transform: perspective(500px) rotateX(0deg); }
@media (prefers-reduced-motion: reduce) {
.fx-perspective-text, .fx-perspective-text::before, .fx-perspective-text::after, .fx-perspective-text *, .fx-perspective-text *::before, .fx-perspective-text *::after { animation: none !important; transition: none !important; }
}3Matrix Transform
Uses a single matrix() to scale, skew and lift a tile at once on hover. Class: fx-matrix-transform
<div class="d-flex flex-wrap align-items-center justify-content-center gap-3 p-3 h-100" style="min-height:200px">
<a href="#" class="fx-matrix-transform d-block text-decoration-none rounded-4 p-4 text-white" style="width:13rem;background:linear-gradient(135deg, var(--wt-primary), var(--wt-secondary))">
<div class="fs-2">
<i class="bi bi-bounding-box" aria-hidden="true"></i>
</div>
<div class="fw-semibold">
Corporate cards
</div>
<div class="small opacity-75">
Hover me
</div>
</a>
</div>
/* CSS (already in assets/css/effects.css) */
.fx-matrix-transform { transition: transform .5s cubic-bezier(.34, 1.56, .64, 1), box-shadow .5s; }
.fx-matrix-transform:hover, .fx-matrix-transform:focus-visible { transform: matrix(1.05, -.08, .12, 1.05, 0, -8); box-shadow: 0 20px 30px -16px rgba(var(--wt-primary-rgb), .5); }
@media (prefers-reduced-motion: reduce) {
.fx-matrix-transform, .fx-matrix-transform::before, .fx-matrix-transform::after, .fx-matrix-transform *, .fx-matrix-transform *::before, .fx-matrix-transform *::after { animation: none !important; transition: none !important; }
}