The CSS backface-visibility property hides an element’s back when a transform turns that side away from the viewer. Applied to both faces of a virtual credit card, it makes only the front-facing side visible during a 3D flip. section 9.5.2
A working card flip combines several declarations:
- Set backface-visibility: hidden on both card sides so the side facing away disappears. section 9.5.2
- Use transform-style: preserve-3d on the card container to establish front-and-back depth. section 9.5.2
- Rotate the back with transform: rotateY(-180deg), then rotate the whole card on hover. section 9.5.1 section 9.5.2
- Overlay the two faces with relative positioning on the container and absolute positioning on the back. section 9.5.1
- Place the interaction inside @media (hover: hover); devices without hover show both sides instead. section 9.5.1
Virtual credit card
A front-and-back credit card uses the property to hide the mirrored back while the card rests in its default state. Hovering rotates the card 180 degrees on the y-axis, revealing the back and hiding the front; a transition can make the change appear as a physical flip. section 9.0 section 9.5.2
Listing 9.23 Hiding the back and exposing it on hover
@media (hover: hover) {
...
.card-item {
transform-style: preserve-3d; #1
}
.card-item__side {
backface-visibility: hidden; #2
}
.card-item:hover { #3
transform: rotateY(180deg); #3
} #3
}
The CSS listing shows the container’s 3D setup, hidden card sides, and hover rotation together. section 9.5.2
