- html>
- <html lang="en">
-
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Documenttitle>
- <style>
- body {
- padding: 50px;
- }
-
- div {
- width: 50px;
- height: 100px;
- background-color: aquamarine;
- font-size: 24px;
- text-align: center;
- animation: goIn 1s ease-in-out infinite;
- }
-
- @keyframes goIn {
- 0% {
- transform: translate(-50%, -50%) rotate(120deg);
- }
-
- 20% {
- transform: translate(-50%, -50%) rotate(-20deg);
- }
-
- 40% {
- transform: translate(-50%, -50%) rotate(10deg);
- }
-
- 60% {
- transform: translate(-50%, -50%) rotate(0deg);
- }
-
- 80% {
- transform: translate(-50%, -50%) rotate(20deg);
- }
-
- 100% {
- transform: translate(-50%, -50%) rotate(-120deg);
- }
- }
- style>
- head>
-
- <body>
- <div>5div>
- <script>
- let numEl = document.getElementsByTagName("div")[0]
- let timer = null
- let num = 5
-
- function countDown() {
- if (num > 0) {
- num--
- numEl.innerText = num
- console.log(num);
- } else {
- numEl.style.animation = 'none'
- clearInterval(timer)
- }
- }
- setInterval(() => {
- countDown()
- }, 1000)
- script>
- body>
-
- html>