backface-visibility
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2022ë 3ì.
CSS backface-visibility ìì±ì ììì ë·ë©´ì´ ì¬ì©ì를 í¥í ë ë³´ì¬ì¼ íëì§ ì§ì í©ëë¤.
ìëí´ ë³´ê¸°
backface-visibility: visible;
backface-visibility: hidden;
<section class="default-example" id="default-example">
<div id="example-element">
<div class="face front">1</div>
<div class="face back">2</div>
<div class="face right">3</div>
<div class="face bottom">6</div>
</div>
</section>
#default-example {
background: linear-gradient(skyblue, khaki);
}
#example-element {
width: 100px;
height: 100px;
perspective: 550px;
perspective-origin: 220% 220%;
transform-style: preserve-3d;
}
.face {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
position: absolute;
backface-visibility: inherit;
background: rgba(0, 0, 0, 0.4);
font-size: 60px;
color: white;
}
.front {
transform: translateZ(50px);
}
.back {
background: rgb(230, 0, 0);
color: white;
transform: rotateY(180deg) translateZ(50px);
}
.right {
background: rgba(0, 0, 0, 0.6);
transform: rotateY(90deg) translateZ(50px);
}
.bottom {
background: rgba(0, 0, 0, 0.6);
transform: rotateX(-90deg) translateZ(50px);
}
ììì ë·ë©´ì ìë©´ì ê±°ì¸ìì ëë¤. 2D ìíììë ë³¼ ì ìì§ë§ ë³íì íµí´ 3D ê³µê°ìì íì ëë©´ ë ¸ì¶ë ì ììµëë¤. (2D ë³íìë ìê·¼ì´ ìì¼ë¯ë¡ í¨ê³¼ê° ììµëë¤.)
구문
/* í¤ìë ê° */
backface-visibility: visible;
backface-visibility: hidden;
/* ì ì ê° */
backface-visibility: inherit;
backface-visibility: initial;
backface-visibility: unset;
backface-visibility ìì±ì ë¤ì 목ë¡ì í¤ìë ì¤ íë를 ì íí´ ì§ì í ì ììµëë¤.
ê°
visible-
ë·ë©´ì´ ì¬ì©ì를 í¥íë©´ ë³´ì ëë¤.
-
ë·ë©´ì´ ì¬ì©ì를 í¥í´ë ë³´ì´ì§ ììµëë¤. ììê° ë¤ë¥¼ í¥íë©´ ì¬ì©ìë¡ë¶í° ì¨ê¸°ë ê²ê³¼ ê°ìµëë¤.
íì ì ì
| ì´ê¸°ê° | visible |
|---|---|
| ì ì©ëì | transformable elements |
| ìì | no |
| ê³ì° ê° | as specified |
| Animation type | discrete |
íì 구문
backface-visibility =
visible |
hidden
ìì
>ì¡ë©´ì²´ì ë·ë©´ ë¹êµ
ìë ìì ë í¬ëª í ë·ë©´ì ì¡ë©´ì²´ì ë¶í¬ëª í ë·ë©´ì ì¡ë©´ì²´ë¥¼ íëì© ë³´ì ëë¤.
HTML
<table>
<tr>
<th><code>backface-visibility: visible;</code></th>
<th><code>backface-visibility: hidden;</code></th>
</tr>
<tr>
<td>
<div class="container">
<div class="cube showbf">
<div class="face front">1</div>
<div class="face back">2</div>
<div class="face right">3</div>
<div class="face left">4</div>
<div class="face top">5</div>
<div class="face bottom">6</div>
</div>
</div>
<p>
Since all faces are partially transparent, the back faces (2, 4, 5) are
visible through the front faces (1, 3, 6).
</p>
</td>
<td>
<div class="container">
<div class="cube hidebf">
<div class="face front">1</div>
<div class="face back">2</div>
<div class="face right">3</div>
<div class="face left">4</div>
<div class="face top">5</div>
<div class="face bottom">6</div>
</div>
</div>
<p>The three back faces (2, 4, 5) are hidden.</p>
</td>
</tr>
</table>
CSS
/* Classes that will show or hide the
three back faces of the "cube" */
.showbf div {
backface-visibility: visible;
}
.hidebf div {
backface-visibility: hidden;
}
/* Define the container div, the cube div, and a generic face */
.container {
width: 150px;
height: 150px;
margin: 75px 0 0 75px;
border: none;
}
.cube {
width: 100%;
height: 100%;
perspective: 550px;
perspective-origin: 150% 150%;
transform-style: preserve-3d;
}
.face {
display: block;
position: absolute;
width: 100px;
height: 100px;
border: none;
line-height: 100px;
font-family: sans-serif;
font-size: 60px;
color: white;
text-align: center;
}
/* Define each face based on direction */
.front {
background: rgba(0, 0, 0, 0.3);
transform: translateZ(50px);
}
.back {
background: rgba(0, 255, 0, 1);
color: black;
transform: rotateY(180deg) translateZ(50px);
}
.right {
background: rgba(196, 0, 0, 0.7);
transform: rotateY(90deg) translateZ(50px);
}
.left {
background: rgba(0, 0, 196, 0.7);
transform: rotateY(-90deg) translateZ(50px);
}
.top {
background: rgba(196, 196, 0, 0.7);
transform: rotateX(90deg) translateZ(50px);
}
.bottom {
background: rgba(196, 0, 196, 0.7);
transform: rotateX(-90deg) translateZ(50px);
}
/* Make the table a little nicer */
th,
p,
td {
background-color: #eeeeee;
margin: 0px;
padding: 6px;
font-family: sans-serif;
text-align: left;
}
ê²°ê³¼
ëª ì¸
| Specification |
|---|
| CSS Transforms Module Level 2 > # backface-visibility-property > |