<!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>3d位移</title>
<style>
body{
perspective: 1000px;
}
div{
width: 200px;
height: 200px;
margin: 0 auto;
background-color: yellow;
transform: translateX(100px) translateY(100px) translateZ(100px);
}
/* transform: translateX(100px); */
/* transform: translateY(100px); 不能写完x后继续写y,会覆盖*/
/* transform: translateX(100px) translateY(100px) translateZ(100px); */
/* 用空格隔开 未加透视z轴方向上的位移看不出效果 有透视才有近大远小*/
div:nth-of-type(2){
background-color: green;
transform: translateX(100px) translateY(100px) translateZ(200px);
}
div:nth-of-type(3){
background-color: pink;
transform: translateX(100px) translateY(100px) translateZ(300px);
}
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
</body>
</html>