三维坐标系
三维坐标系其实就是指立体空间,立体空间是由3个轴共同组成的,
x轴:水平向右注意:x右边是正值,左边是负值
y轴:垂直向下注意 :y下面是正值,上面是负值
z轴:垂直屏幕注意:往外面是正值,往里面是负值
3D移动translate3d(x,y,z)
3D旋转rotated3d(x,y,z,deg) x,y,z是矢量,用1或0表示,表示是否旋转。
3D呈现translate-style:perserve-3d; -----这个属性很重要
两面翻转案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
perspective: 400px;
}
.box {
position: relative;
width: 300px;
height: 300px;
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: 30px;
color: #fff;
text-align: center;
line-height: 300px;
}
.front {
background-color: pink;
z-index: 1;
}
.back {
background-color: purple;
/* 像手机一样 背靠背 旋转 */
transform: rotateY(180deg);
}
</style>
</head>
<body>
<div class="box">
<div class="front">前面</div>
<div class="back">后面</div>
</div>
</body>
</html>