1、盒子反转
2、保留子元素3d空间,transform-style: preserve-3d;
3、隐藏子盒子的背面,backface-visibility: hidden;
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style>
body{
perspective:350px;
}
.box {
position: relative;
width: 200px;
height: 200px;
margin: 100px auto;
transition: all .4s;
transform-style: preserve-3d;
}
.box:hover {
transform: rotateY(180deg);
}
.front,
.back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
font-size: 20px;
color:white;
text-align: center;
line-height:200px;
backface-visibility: hidden;
}
.front{
z-index:2;
background-color:pink;
}
.back {
background-color: purple;
transform:rotateY(180deg);
}
</style>
</head>
<body>
<div class="box">
<div class="front">正面</div>
<div class="back">反面</div>
</div>
</body>
</html>