-
Notifications
You must be signed in to change notification settings - Fork 1
/
css_3dcube.html
78 lines (68 loc) · 1.65 KB
/
css_3dcube.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Rotating Cube</title>
<style>
/* Add the CSS code here */
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
margin: 0;
perspective: 1000px;
}
.cube {
position: relative;
width: 200px;
transform-style: preserve-3d;
animation: rotateCube 2s infinite linear;
}
.face {
position: absolute;
width: 200px;
height: 200px;
background: rgba(0, 128, 255, 0.7);
border: 1px solid #000;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
color: white;
}
.front { transform: translateZ(100px); }
.back { transform: rotateY(180deg) translateZ(100px); }
.right { transform: rotateY(90deg) translateZ(100px); }
.left { transform: rotateY(-90deg) translateZ(100px); }
.top { transform: rotateX(90deg) translateZ(100px); }
.bottom { transform: rotateX(-90deg) translateZ(100px); }
@keyframes rotateCube {
0% {
transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
}
33% {
transform: rotateX(360deg) rotateY(0deg) rotateZ(0deg);
}
66% {
transform: rotateX(360deg) rotateY(360deg) rotateZ(0deg);
}
100% {
transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg);
}
}
</style>
</head>
<body>
<div class="cube">
<div class="face front">Front</div>
<div class="face back">Back</div>
<div class="face right">Right</div>
<div class="face left">Left</div>
<div class="face top">Top</div>
<div class="face bottom">Bottom</div>
</div>
</body>
</html>