<!DOCTYPE html>
<html>
<head>
<style>
#Heading {
position: absolute;
user-select: none;
font-family: 'Poppins', sans-serif;
font-size: 100px;
left: 35.8%;
}
#first {
position: absolute;
user-select: none;
top: 26%;
left: 24%;
background-color: grey;
padding: 10vh;
border: 4px solid lightblue ;
}
#second {
position: absolute;
user-select: none;
top: 26%;
left: 40%;
background-color: grey;
padding: 10vh;
border: 4px solid lightblue ;
}
#third {
position: absolute;
user-select: none;
top: 26%;
left: 56%;
background-color: grey;
padding: 10vh;
border: 4px solid lightblue ;
}
#fourth {
position: absolute;
user-select: none;
top: 49%;
left: 56%;
background-color: grey;
padding: 10vh;
border: 4px solid lightblue ;
}
#fifth {
position: absolute;
user-select: none;
top: 49%;
left: 40%;
background-color: grey;
padding: 10vh;
border: 4px solid lightblue ;
}
#sixth {
position: absolute;
user-select: none;
top: 49%;
left: 24.1%;
background-color: grey;
padding: 10vh;
border: 4px solid lightblue ;
}
#first:hover {
background-color: aquamarine;
border-color: aquamarine;
}
#second:hover {
background-color: aquamarine;
border-color: aquamarine;
}
#third:hover {
background-color: aquamarine;
border-color: aquamarine;
}
#fourth:hover {
background-color: aquamarine;
border-color: aquamarine;
}
#fifth:hover {
background-color: aquamarine;
border-color: aquamarine;
}
#sixth:hover {
background-color: aquamarine;
border-color: aquamarine;
}
.animate {
animation-name: rotate;
animation-duration: 2s;
}
@keyframes rotate {
from { transform: rotateY(0deg); }
to { transform: rotateY(180deg); }
}
</style>
</head>
<body>
<span id="Heading">Memory</span>
<div id="first" onclick="animate(event)"></div>
<div id="second" onclick="animate(event)"></div>
<div id="third" onclick="animate(event)"></div>
<div id="fourth" onclick="animate(event)"></div>
<div id="fifth" onclick="animate(event)"></div>
<div id="sixth" onclick="animate(event)"></div>
<script>
let angle = 0;
function animate(event) {
let element = event.target;
angle += 180;
let start = null;
function step(timestamp) {
if (!start) start = timestamp;
let progress = timestamp - start;
let currentAngle = angle - 180 * (1 - progress / 2000);
element.style.transform = `rotateY(${currentAngle}deg)`;
if (progress < 2000) {
requestAnimationFrame(step);
}
}
requestAnimationFrame(step);
}
</script>
</body>
</html>
I tried to make an Animation, where the div element turns 360 degrees, but everytime i try it, there is no Animation visible. I already tried to make a code in css. I also tried another Browser and restarting the Computer but it didnt work out. I already asked some AIs but they couldnt tell me wheres the Problem.