---
title: backface-visibility
slug: Web/CSS/backface-visibility
translation_of: Web/CSS/backface-visibility
---
<div>{{CSSRef}}{{SeeCompatTable}}</div>

<p><a href="/en-US/docs/Web/CSS">CSS</a> 属性 <strong><code>backface-visibility</code></strong> 指定当元素背面朝向观察者时是否可见。</p>

<div>{{EmbedInteractiveExample("pages/css/backface-visibility.html")}}</div>



<p>元素的背面是其正面的镜像。虽然在 2D 中不可见,但是当变换导致元素在 3D 空间中旋转时,背面可以变得可见。 (此属性对 2D 变换没有影响,它没有透视。)</p>

<h2 id="语法">语法</h2>

<pre class="brush:css no-line-numbers">/* Keyword values */
backface-visibility: visible;
backface-visibility: hidden;

/* Global values */
backface-visibility: inherit;
backface-visibility: initial;
backface-visibility: unset;</pre>

<p><code>backface-visibility</code> 属性可以指定为下面列出的值</p>

<h3 id="值">值</h3>

<dl>
 <dt><code>visible</code></dt>
 <dd>背面朝向用户时可见。</dd>
 <dt><code>hidden</code></dt>
 <dd>背面朝向用户时不可见。</dd>
</dl>

<h3 id="正式语法">正式语法</h3>

{{csssyntax}}

<h2 id="举例">举例</h2>

<p>这个示例展示了一个拥有透明表面的立方体。</p>

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;&lt;code&gt;backface-visibility: visible;&lt;/code&gt;&lt;/th&gt;
    &lt;th&gt;&lt;code&gt;backface-visibility: hidden;&lt;/code&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;div class="container"&gt;
        &lt;div class="cube showbf"&gt;
          &lt;div class="face front"&gt;1&lt;/div&gt;
          &lt;div class="face back"&gt;2&lt;/div&gt;
          &lt;div class="face right"&gt;3&lt;/div&gt;
          &lt;div class="face left"&gt;4&lt;/div&gt;
          &lt;div class="face top"&gt;5&lt;/div&gt;
          &lt;div class="face bottom"&gt;6&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;
        Since all faces are partially transparent,
        the back faces (2, 4, 5) are visible
        through the front faces (1, 3, 6).
      &lt;/p&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;div class="container"&gt;
        &lt;div class="cube hidebf"&gt;
          &lt;div class="face front"&gt;1&lt;/div&gt;
          &lt;div class="face back"&gt;2&lt;/div&gt;
          &lt;div class="face right"&gt;3&lt;/div&gt;
          &lt;div class="face left"&gt;4&lt;/div&gt;
          &lt;div class="face top"&gt;5&lt;/div&gt;
          &lt;div class="face bottom"&gt;6&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;
        The three back faces (2, 4, 5) are
        hidden.
      &lt;/p&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: 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;
}</pre>

<h3 id="结果">结果</h3>

<p>{{EmbedLiveSample('Example', '100%', 360)}}</p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS Transforms 2', '#propdef-backface-visibility', 'backface-visibility')}}</td>
   <td>{{Spec2('CSS Transforms 2')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<p>{{cssinfo}}</p>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("css.properties.backface-visibility")}}</p>

<h2 id="相关连接">相关连接</h2>

<ul>
 <li><a href="/en-US/docs/Web/CSS/CSS_Transforms/Using_CSS_transforms">Using CSS transforms</a></li>
</ul>