Rotating 3d cube

Developer
Size
2,957 Kb
Views
10,120

How do I make an rotating 3d cube?

Practicing with css 3d effects. What is a rotating 3d cube? How do you make a rotating 3d cube? This script and codes were developed by Chris Hanson on 01 October 2022, Saturday.

Rotating 3d cube Previews

Rotating 3d cube - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Rotating 3d cube</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ * { box-sizing: border-box;
}
body { background: #a7afb9;
}
.container { width: 210px; height: 210px; margin: 100px auto;
}
.cube { width: 100%; height: 100%; color: rgba(255, 255, 255, 0.66); text-align: center; line-height: 180px; font-size: 10em; transform-style: preserve-3d; animation: anim 3s linear infinite;
}
.cube .face { width: 100%; height: 100%; position: absolute; border: 15px solid rgba(255, 255, 255, 0.33); background: rgba(0, 0, 0, 0.5);
}
.cube .face:nth-child(1) { transform: translateZ(105px);
}
.cube .face:nth-child(2) { transform: rotateY(-180deg) translateZ(105px);
}
.cube .face:nth-child(3) { transform: rotateY(90deg) translateZ(105px);
}
.cube .face:nth-child(4) { transform: rotateY(-90deg) translateZ(105px);
}
.cube .face:nth-child(5) { transform: rotateX(90deg) translateZ(105px);
}
.cube .face:nth-child(6) { transform: rotateX(-90deg) translateZ(105px);
}
@keyframes anim { to { transform: rotateX(360deg) rotateY(360deg); }
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class='container'> <div class='cube'> <div class='face'> 1 </div> <div class='face'> 2 </div> <div class='face'> 3 </div> <div class='face'> 4 </div> <div class='face'> 5 </div> <div class='face'> 6 </div> </div>
</div>
</body>
</html>

Rotating 3d cube - Script Codes CSS Codes

* { box-sizing: border-box;
}
body { background: #a7afb9;
}
.container { width: 210px; height: 210px; margin: 100px auto;
}
.cube { width: 100%; height: 100%; color: rgba(255, 255, 255, 0.66); text-align: center; line-height: 180px; font-size: 10em; transform-style: preserve-3d; animation: anim 3s linear infinite;
}
.cube .face { width: 100%; height: 100%; position: absolute; border: 15px solid rgba(255, 255, 255, 0.33); background: rgba(0, 0, 0, 0.5);
}
.cube .face:nth-child(1) { transform: translateZ(105px);
}
.cube .face:nth-child(2) { transform: rotateY(-180deg) translateZ(105px);
}
.cube .face:nth-child(3) { transform: rotateY(90deg) translateZ(105px);
}
.cube .face:nth-child(4) { transform: rotateY(-90deg) translateZ(105px);
}
.cube .face:nth-child(5) { transform: rotateX(90deg) translateZ(105px);
}
.cube .face:nth-child(6) { transform: rotateX(-90deg) translateZ(105px);
}
@keyframes anim { to { transform: rotateX(360deg) rotateY(360deg); }
}
Rotating 3d cube - Script Codes
Rotating 3d cube - Script Codes
Home Page Home
Developer Chris Hanson
Username chrishanson
Uploaded October 01, 2022
Rating 3
Size 2,957 Kb
Views 10,120
Do you need developer help for Rotating 3d cube?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Chris Hanson (chrishanson) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!