<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
body{
background-color: black;
overflow: hidden;
}
ul{
width: 300px;
height: 300px;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
/* 制作一个3d空间 */
transform-style: preserve-3d;
animation: box 20s linear infinite;
}
@keyframes box{
from{
transform: rotate3d(0,0,0,0deg);
}
to{
transform: rotate3d(1,1,1,360deg);
}
}
ul li{
width: 300px;
height: 300px;
border: 1px solid blue;
list-style: none;
position: absolute;
text-align: center;
line-height: 300px;
font-size: 40px;
font-weight: bold;
color: white;
opacity: 0.8;
border-radius: 20px;
}
/* 正面 */
li:nth-child(1){
background: red;
transform: translateZ(150px);
}
/* 左面 */
li:nth-child(2){
background: blue;
transform: translateX(-150px) rotateY(-90deg);
}
/* 右面 */
li:nth-child(3){
background: blue;
transform: translateX(150px) rotateY(90deg);
}
/* 上面 */
li:nth-child(4){
background: green;
transform: translateY(-150px) rotateX(90deg);
}
/* 下面 */
li:nth-child(5){
background: purple;
transform: translateY(150px) rotateX(-90deg);
}
/* 下面 */
li:nth-child(6){
background: orange;
transform: translateZ(-150px) rotateY(180deg);
}
</style>
</head>
<body>
<ul>
<li>正</li>
<li>左</li>
<li>右</li>
<li>上</li>
<li>下</li>
<li>后</li>
</ul>
</body>
</html>
效果图: