<!-- 样式 -->
<style>
* {
margin: 0;
padding: 0;
}
:root,
html,
body {
width: 100%;
height: 100%;
background-color: bisque;
perspective: 800px;
}
.wrapper {
width: 300px;
height: 300px;
box-sizing: border-box;
position: absolute;
border: 1px solid #dddd;
top: calc(50% - 150px);
left: calc(50% - 150px);
transform-style: preserve-3d;
transform: rotateX(20deg) rotateY(30deg) rotateZ(50deg);
}
.wrapper div {
width: 100%;
height: 100%;
position: absolute;
font-size: 100px;
display: flex;
justify-content: center;
align-items: center;
}
/* 前面 */
.wrapper div:nth-of-type(1) {
background-color: #ff0;
color: #fff;
transform: translateZ(150px);
opacity: 0.5;
}
/* 后面 */
.wrapper div:nth-of-type(2) {
background-color: rgb(41, 170, 95);
color: #000;
transform: translateZ(-150px);
opacity: 0.5;
}
/* 上面 */
.wrapper div:nth-of-type(3) {
background-color: rgb(24, 194, 194);
color: #fff;
transform: rotateX(90deg) translateZ(150px) ;
opacity: 0.5;
}
/* 下面 */
.wrapper div:nth-of-type(4) {
background-color: rgb(46, 100, 201);
color: #000;
transform: rotateX(90deg) translateZ(-150px) ;
opacity: 0.5;
}
/* 左边 */
.wrapper div:nth-of-type(5) {
background-color: rgb(228, 78, 135);
color: #000;
transform: rotateY(90deg) translateZ(-150px) ;
opacity: 0.5;
}
/* 右边 */
.wrapper div:nth-of-type(6) {
background-color: rgb(153, 50, 156);
color: #fff;
transform: rotateY(90deg) translateZ(150px) ;
opacity: 0.5;
}
</style>