- X 轴 往右越大,是正值, 否则反之
- Y 轴 往下越大,是正值,否则反之
- Z轴 (指向我们)越大,是正值,否则反之
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
transform-style: preserve-3d;
position: relative;
width: 200px;
height: 200px;
margin: 30px auto;
background-color: palevioletred;
transition: all 2s;
}
.box>div {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
transition: all 2s;
}
.one {
transform: translateZ(-100px);
background-color: palegreen;
}
.two {
transform: translateZ(100px);
background-color: peru;
}
.box:hover {
transform: rotateY(180deg);
}
</style>
</head>
<body>
<div class="box">
<div class="one"></div>
<div class="two"></div>
</div>
</body>
</html>