<html>
<head>
<title>3D立方体</title>
<style>
.top {
background-color: blue;
width: 200px;
height: 200px;
position: absolute;
left: 0;
top: 0;
transform: translateY(-100px) rotateX(90deg);
}
.bottom {
background-color: aqua;
width: 200px;
height: 200px;
position: absolute;
left: 0;
top: 0;
transform: translateY(100px) rotateX(-90deg);
}
.left {
background-color: blueviolet;
width: 200px;
height: 200px;
position: absolute;
left: 0;
top: 0;
transform: translateX(-100px) rotateY(-90deg);
}
.right {
background-color: bisque;
width: 200px;
height: 200px;
position: absolute;
left: 0;
top: 0;
transform: translateX(100px) rotateY(90deg);
}
.front {
background-color: pink;
width: 200px;
height: 200px;
position: absolute;
left: 0;
top: 0;
transform: translateZ(100px);
}
.back {
background-color: goldenrod;
width: 200px;
height: 200px;
position: absolute;
left: 0;
top: 0;
transform: translateZ(-100px) rotateY(180deg);
}
.rotateSquare {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
transform-style: preserve-3d;
width: 200px;
height: 200px;
transform: rotateY(20deg) rotateX(20deg);
animation:changeSolution 8s infinite linear;
text-align: center;
font-size: 125px;
}
@keyframes changeSolution{
0% {transform: rotateX(0deg) rotateY(0deg);}
25% {transform: rotateX(90deg) rotateY(90deg);}
50% {transform: rotateX(180deg) rotateY(180deg);}
75% {transform: rotateX(270deg) rotateY(270deg);}
100% {transform: rotateX(360deg) rotateY(360deg);}
}
</style>
<script></script>
</head>
<body>
<div class="rotateSquare">
<div class="top">大</div>
<div class="bottom">家</div>
<div class="left">新</div>
<div class="right">年</div>
<div class="front">快</div>
<div class="back">乐</div>
</div>
</body>
</html>
css3D旋转正方体
最新推荐文章于 2022-05-17 22:12:51 发布