- 话不多说,直接上代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="fk.PNG">
<title>css3D盒子</title>
<style>
html{
perspective: 1000px;
background-color: black;
}
.box{
width: 200px;
height: 200px;
margin: 300px auto;
position: relative;
transform-style: preserve-3d;
animation: xuanzhuan 5s infinite linear;
}
@keyframes xuanzhuan {
0%{
transform: rotateX(0) rotateY(0) ;
}
100%{
transform: rotateX(360deg) rotateY(360deg) ;
}
}
.box>div{
width: 100%;
height: 100%;
position: absolute;
text-align: center;
line-height: 200px;
}
.front{
background-image: linear-gradient(160deg, #b100ff 20%,#00b3ff 80%);
}
.back{
background-image: linear-gradient(160deg, #ff0064 20%,#ca00ff 80%);
}
.left{
background-image: linear-gradient(160deg, #0078ff 20%,#ca00ff 80%);
}
.right{
background-image: linear-gradient(160deg, #00ffd5 20%,#008cff 80%);
}
.top{
background-image: linear-gradient(160deg, darkorchid 20%,#00b3ff 80%);
}
.bottom{
background-image: linear-gradient(160deg, #a200ff 20%,#cf3700 80%);
}
</style>
</head>
<body>
<div class="box" id="box">
<div class="front"></div>
<div class="back"></div>