立方体
2024-06-25 本文已影响0人
xueyueshuai
![](https://img.haomeiwen.com/i16376398/8528c6d386aa34fe.png)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.cube {
margin-top: 100px;
margin-left: 100px;
position: relative;
width: 200px;
height: 200px;
transform-style: preserve-3d;
animation: spin 10s infinite linear;
}
.face {
position: absolute;
width: 200px;
height: 200px;
}
.front {
background-color: rgba(255, 0, 0, 0.71);
transform: translateZ(100px);
}
.back {
background-color: rgba(0, 0, 255, 0.81);
transform: translateZ(-100px) rotateY(180deg);
}
.right {
background-color: rgba(0, 128, 0, 0.71);
transform: rotateY(90deg) translateZ(100px);
}
.left {
background-color: rgba(255, 255, 0, 0.78);
transform: rotateY(-90deg) translateZ(100px);
}
.top {
background-color: rgba(255, 165, 0, 0.76);
transform: rotateX(90deg) translateZ(100px);
}
.bottom {
background-color: rgba(128, 0, 128, 0.7);
transform: rotateX(-90deg) translateZ(100px);
}
@keyframes spin {
to { transform: rotate3d(1,1,1, 360deg) }
}
</style>
</head>
<body>
<div class="cube">
<div class="face front"></div>
<div class="face back"></div>
<div class="face right"></div>
<div class="face left"></div>
<div class="face top"></div>
<div class="face bottom"></div>
</div>
</body>
</html>