<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D立方体</title>
<style>
.box{
width: 249px;
height: 249px;
border: 1px dashed #000;
margin: 120px auto;
border-radius: 250px;
position: relative;
transform-style: preserve-3d;
animation: gun 8s linear infinite;
}
.box::before,.box::after{
content: "";
width: 50px;
height: 80px;
background: pink;
position: absolute;
border-radius: 50px 50px 0 0;
top: 50%;
left: 50%;
}
.box::before{
transform: rotate(-45deg);
margin-left: -36px;
margin-top: -40px;
}
.box::after{
transform: rotate(45deg);
margin-left: -16px;
margin-top: -40px;
}
@keyframes gun{
0%{
transform:rotateX(0deg) rotateY(0deg)
}
100%{
transform:rotateX(360deg) rotateY(360deg)
}
}
.box > div{
width: 100%;
height: 100%;
text-align: center;
line-height: 250px;
font-size: 60px;
position: absolute;
color: #fff;
}
.left{
background-color: rgba(255,0,0,0.3);
transform-origin: left;
transform: rotateY(-90deg) translateX(-125px);
}
.right{
background-color:rgba(0,255,0,0.3);
transform-origin: right;
transform: rotateY(90deg)translateX(125px);
}
.forward{
background-color: rgba(0,0,255,0.3);
transform: translateZ(125px);
}
.back{
background-color: rgba(0,125,125,0.3);
transform: rotateY(-180deg) translateZ(125px);
}
.up{
background-color: rgba(125,125,0,0.3);
transform: rotateX(90deg) translateZ(125px);
}
.down{
background-color: rgba(125,125,225,0.3);
transform: rotateX(-90deg) translateZ(125px);
}
</style>
</head>
<body>
<div class = "box">
<div class = "up">上</div>
<div class = "down">下</div>
<div class = "left">左</div>
<div class = "right">右</div>
<div class = "forward">前</div>
<div class = "back">后</div>
</div>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D立方体</title>
<style>
.box{
width: 249px;
height: 249px;
border: 1px dashed #000;
margin: 120px auto;
border-radius: 250px;
position: relative;
transform-style: preserve-3d;
animation: gun 8s linear infinite;
}
.box::before,.box::after{
content: "";
width: 50px;
height: 80px;
background: pink;
position: absolute;
border-radius: 50px 50px 0 0;
top: 50%;
left: 50%;
}
.box::before{
transform: rotate(-45deg);
margin-left: -36px;
margin-top: -40px;
}
.box::after{
transform: rotate(45deg);
margin-left: -16px;
margin-top: -40px;
}
@keyframes gun{
0%{
transform:rotateX(0deg) rotateY(0deg)
}
100%{
transform:rotateX(360deg) rotateY(360deg)
}
}
.box > div{
width: 100%;
height: 100%;
text-align: center;
line-height: 250px;
font-size: 60px;
position: absolute;
color: #fff;
}
.left{
background-color: rgba(255,0,0,0.3);
transform-origin: left;
transform: rotateY(-90deg) translateX(-125px);
}
.right{
background-color:rgba(0,255,0,0.3);
transform-origin: right;
transform: rotateY(90deg)translateX(125px);
}
.forward{
background-color: rgba(0,0,255,0.3);
transform: translateZ(125px);
}
.back{
background-color: rgba(0,125,125,0.3);
transform: rotateY(-180deg) translateZ(125px);
}
.up{
background-color: rgba(125,125,0,0.3);
transform: rotateX(90deg) translateZ(125px);
}
.down{
background-color: rgba(125,125,225,0.3);
transform: rotateX(-90deg) translateZ(125px);
}
</style>
</head>
<body>
<div class = "box">
<div class = "up">上</div>
<div class = "down">下</div>
<div class = "left">左</div>
<div class = "right">右</div>
<div class = "forward">前</div>
<div class = "back">后</div>
</div>
</body>
</html>