老师我这样写可以吗?背面直接沿Z轴-100px
来源:2-12 空间移动
激情的樱木花道
2021-05-31 11:49:29
<!DOCTYPE html>
<html lang="en">
<!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>
* {
margin: 0;
padding: 0;
}
.box{
width: 200px;
height: 200px;
border: 1px solid #000;
margin:100px auto;
perspective: 300px;
position:relative;
}
.box p{
position:absolute;
top:0;
left:0;
width: 200px;
height: 200px;
}
.box p:nth-child(1){
background-color: rgba(216, 109, 114, 0.45);
/* 前面 */
transform: translateZ(100px);
}
.box p:nth-child(2){
background-color: rgba(49, 119, 40, 0.45);
/* 顶部 */
transform: rotateX(90deg) translateZ(100px);
}
.box p:nth-child(3){
background-color: rgba(147, 76, 150, 0.45);
/* 背面 */
/* transform:rotateX(180deg) translateZ(100px); */
transform:translateZ(-100px);
}
.box p:nth-child(4){
background-color: rgba(35, 25, 133, 0.45);
/* 底面 */
transform: rotateX(90deg) translateZ(-100px);
}
.box p:nth-child(5){
background-color: rgba(53, 123, 170, 0.45);
/* 左侧面 */
transform: rotateY(90deg) translateZ(-100px);
}
.box p:nth-child(6){
background-color: rgba(135, 153, 33, 0.45);
/* 右侧面 */
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回答
好帮手慕言
2021-05-31
同学你好,背面设置transform: translateZ(-100px)也是可以实现效果的。祝学习愉快~
相似问题
回答 4
回答 2