<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Acties in HTML</title>
<style>
.character {
width: 50px;
height: 50px;
background-color: lightblue;
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
}
@keyframes moveRight {
0% { left: 0; }
100% { left: 300px; }
}
@keyframes rotate {
0% { transform: translate(300px, -50%) rotate(0deg); }
100% { transform: translate(300px, -50%) rotate(90deg); }
}
@keyframes bow {
0% { transform: rotate(90deg); }
50% { transform: rotate(90deg) scaleY(0.5); }
100% { transform: rotate(90deg); }
}
</style>
</head>
<body>
<div class="character" id="character"></div>
<script>
const character = document.getElementById('character');
function moveRight() {
character.style.animation = 'moveRight 2s forwards';
setTimeout(turn, 2000);
}
function turn() {
character.style.animation = 'rotate 1s forwards';
setTimeout(sayHello, 1000);
}
function sayHello() {
alert("Hallo!");
setTimeout(bow, 500);
}
function bow() {
character.style.animation = 'bow 2s forwards';
}
moveRight();
</script>
</body>
</html>