backface-visibility
Definition
The backface-visibility property in CSS is used to control whether or not the backface of an element is visible when it is rotated or flipped.
Examples
Hiding the backface of an element when it is rotated:
.rotated-element {
backface-visibility: hidden;
transform: rotateY(180deg);
}
Showing the backface of an element when it is flipped:
.flipped-element {
backface-visibility: visible;
transform: scaleX(-1);
}
Hiding the backface of an element when it is animated:
.animated-element {
backface-visibility: hidden;
animation: spin 1s linear infinite;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
Values
| Value | Description |
|---|---|
visible | The backface of the element is visible. |
hidden | The backface of the element is hidden. |
Best Practices
- Use the
backface-visibilityproperty in conjunction with thetransformproperty to control the visibility of the backface of an element when it is rotated or flipped. - Consider using the
backface-visibilityproperty in combination with animations to create more complex effects. - Avoid using the
backface-visibilityproperty on elements that are frequently updated or animated, as this can impact performance. - Use the
backface-visibilityproperty in combination with media queries to create responsive layouts that adapt to different screen sizes and resolutions.
Browser Compatibility
| Chrome | Firefox | Safari | Internet Explorer | Microsoft Edge | Opera |
|---|---|---|---|---|---|
| Yes | Yes | Yes | No | Yes | Yes |