Strange-Animation
by velo_ninja
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animated Circular 3D Colored Divs</title>
<style>
.container {
width: 300px;
height: 300px;
perspective: 1000px;
margin: 0 auto;
transform-style: preserve-3d;
animation: rotateContainer 10s linear infinite;
}
.colored-div {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100px;
height: 100px;
}
.div1 {background-color: #ff0000;}
.div2 {background-color: #00ff00;}
.div3 {background-color: #0000ff;}
.div4 {background-color: #ffff00;}
.div5 {background-color: #ff00ff;}
</style>
</head>
<body>
<div class="container">
<!-- Colored divs with unique IDs -->
<div id="div1" class="colored-div div1"></div>
<div id="div2" class="colored-div div2"></div>
<div id="div3" class="colored-div div3"></div>
<div id="div4" class="colored-div div4"></div>
<div id="div5" class="colored-div div5"></div>
</div>
<button id="rotateButton">Rotate 3D Space</button>
<script>
const cells = document.querySelectorAll('.colored-div');
function update(cells, pos) {
const radius = 100;
const cellCount = cells.length;
const theta = 360 / cellCount;
cells.forEach((cell, index) => {
const angle = index * theta;
//cell.style.transform = `rotateY(${angle}deg)`;
cell.style.transform = `rotate${'Z'}(${theta*index}deg)`;
cell.style.transform = `translate${'Y'}(${theta*index}deg)`;
});
}
update(cells);
</script>
</body>
</html>
JavaScript
//translateZ(250px)