老师这个translateZ根据什么设置多少合适
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.box {
width: 200px;
height: 200px;
perspective: 400px;
position: relative;
margin: 100px auto;
}
.box p {
width: 200px;
height: 200px;
position: absolute;
top: 0;
left: 0;
}
.box p:nth-child(1) {
background-color: #00ff00de;
/* 前面 */
transform: translateZ(100px);
}
.box p:nth-child(2) {
background-color: rgba(255,255,0,.4);
/* 顶面 */
transform: rotateX(90deg) translateZ(100px);
}
.box p:nth-child(3) {
background-color: #dd12e4de;
/* 后面 */
transform: rotateX(180deg) translateZ(100px);
}
.box p:nth-child(4) {
background-color: hsla(352, 88%, 53%, 0.871);
/* 底面 */
transform: rotateX(-90deg) translateZ(100px);
}
.box p:nth-child(5) {
background-color: hsla(194, 100%, 50%, 0.871);
/* 侧面 */
transform: rotateY(90deg) translateZ(100px);
}
.box p:nth-child(6) {
background-color: rgba(111, 0, 255, 0.871);
transform: rotateY(-90deg) translateZ(100px);
}
</style>
</head>
<body>
<div class="box">
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
</div>
</body>
</html>
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星