有个思路就是用transform的3D转换,有点类似一个正方体;
例子
<html>
<head>
<meta charset=“UTF-8”>
<title>Document</title>
<style>
.a1{
width: 200px;
height: 200px;
margin: 100px auto;
/*border: 1px solid #000;*/
transform-style: preserve-3d;
transform-origin: 50% 50%;
position: relative;
transform: rotateX(45deg) rotateY(45deg);
}
.a1 div{
width: 200px;
height: 200px;
position: absolute;
top: 0;
left: 0;
}
.b1{
background-color: red;
transform: translateX(-100px) rotateY(-90deg);
}
.b2{
background-color: orange;
transform: translateX(100px) rotateY(-90deg);
}
.b3{
background-color: yellow;
transform: translateY(-100px) rotateX(-90deg);
}
.b4{
background-color: green;
transform: translateY(100px) rotateX(-90deg);
}
.b5{
background-color: blue;
transform: translateZ(-100px);
}
.b6{
background-color: purple;
transform: translateZ(100px);
}
</style>
</head>
<body>
<div class=“a1”>
<div class=“b1”></div>
<div class=“b2”></div>
<div class=“b3”></div>
<div class=“b4”></div>
<div class=“b5”></div>
<div class=“b6”></div>
</div>
</body>
</html>