Skip to content

Commit 79577f9

Browse files
committed
3D Rotating Cube
Created a 3D rotating cube using HTML, CSS, and JavaScript.
1 parent dfefd77 commit 79577f9

3 files changed

Lines changed: 101 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### A 3D rotating cube
2+
Created a 3D rotating cube using HTML, CSS, and JavaScript. The end result will be an interactive cube that rotates in 3D space.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Modern Rotating 3D Cube Animation</title>
5+
<link rel="stylesheet" href="styles.css">
6+
</head>
7+
<body>
8+
<div class="container">
9+
<div class="cube">
10+
<div class="face front">
11+
</div>
12+
<div class="face back">
13+
</div>
14+
<div class="face right">
15+
</div>
16+
<div class="face left">
17+
18+
</div>
19+
<div class="face top">
20+
</div>
21+
<div class="face bottom">
22+
</div>
23+
</div>
24+
</div>
25+
</body>
26+
</html>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
body {
2+
background: linear-gradient(to bottom right, #18427d, #5d7ac4);
3+
height: 100vh;
4+
display: flex;
5+
align-items: center;
6+
justify-content: center;
7+
margin: 0;
8+
box-shadow: 0 20px 20px rgba(0, 0, 0, 0.2); /* Updated box-shadow */
9+
10+
}
11+
12+
.container {
13+
perspective: 800px;
14+
15+
}
16+
17+
.cube {
18+
width: 200px;
19+
height: 200px;
20+
position: relative;
21+
transform-style: preserve-3d;
22+
animation: rotate 6s infinite linear;
23+
transform: rotateX(-20deg) rotateY(-30deg);
24+
background: linear-gradient(to bottom right, #695c29, #e67e22);
25+
}
26+
27+
.face {
28+
position: absolute;
29+
width: 200px;
30+
height: 200px;
31+
color: rgb(255, 255, 255);
32+
font-size: 24px;
33+
display: flex;
34+
align-items: center;
35+
justify-content: center;
36+
text-transform: uppercase;
37+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
38+
}
39+
40+
.front {
41+
background: linear-gradient(to bottom right, #477422, #77f12c); transform: translateZ(100px);
42+
}
43+
44+
.back {
45+
background: linear-gradient(to bottom right, #105561, #0ed7e9); transform: translateZ(-100px) rotateY(180deg);
46+
}
47+
48+
.right {
49+
background: linear-gradient(to bottom right, #b8a249, #e67e22); transform: translateX(100px) rotateY(90deg);
50+
}
51+
52+
.left {
53+
background: linear-gradient(to bottom right, #3e8575, #13eca0); transform: translateX(-100px) rotateY(-90deg);
54+
}
55+
56+
.top {
57+
background: linear-gradient(to bottom right, #f1c40f, #e67e22); transform: translateY(-100px) rotateX(90deg);
58+
}
59+
60+
.bottom {
61+
background: linear-gradient(to bottom right, #d16725, #ce905a); transform: translateY(100px) rotateX(-90deg);
62+
}
63+
64+
65+
@keyframes rotate {
66+
0% {
67+
transform: rotateX(-20deg) rotateY(-30deg);
68+
}
69+
100% {
70+
transform: rotateX(340deg) rotateY(330deg);
71+
}
72+
}
73+

0 commit comments

Comments
 (0)