// 外面大盒子
<div class="box">
<div class="front">
正面
</div>
<div class="back">
背面
</div>
</div>
.box {
position: relative;
width: 200px ;
height: 300px ;
margin: 0 auto;
transition: all 3s;
transform-style: preserve-3d; // 打开3d
}
.front, .back {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.front {
width: 200px ;
height: 300px;
background-color: green;
z-index: 1;
backface-visibility: hidden; // 选择隐藏背面
opacity: 1;
}
.back {
width: 200px ;
height: 300px ;
background: rebeccapurple;
transform: rotateY(180deg);
/* transform-style: preserve-3d; */
}
.box:hover {
transform: rotateY(180deg);
}