Created
December 6, 2024 14:55
-
-
Save sunmeat/20c1b66e32e909bc2d099fcb3784682f to your computer and use it in GitHub Desktop.
animations example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="uk"> | |
<head> | |
<meta charset="UTF-8"> | |
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400&family=Caveat:wght@400;700&display=swap" | |
rel="stylesheet"> | |
<title>Анімації</title> | |
<style> | |
body { | |
background-color: #f0f0f0; | |
padding: 10px; | |
text-align: center; | |
font-family: 'Caveat', Arial, sans-serif; | |
font-size: 30px; | |
} | |
table { | |
margin: auto; /*центрування таблиці */ | |
} | |
td { | |
padding: 20px; | |
margin: 20px; | |
text-align: center; | |
} | |
.box { | |
width: 100px; | |
height: 100px; | |
margin: auto; | |
background-color: #4CAF50; | |
border-radius: 10px; | |
} | |
/* анімація 1: пружина */ | |
@keyframes bounce { | |
0%, | |
20%, | |
50%, | |
80%, | |
100% { | |
transform: translateY(0); | |
} | |
40% { | |
transform: translateY(-50px); | |
} | |
60% { | |
transform: translateY(-25px); | |
} | |
} | |
.bounce { | |
animation: bounce 2s infinite; | |
} | |
/* анімація 2: зникнення */ | |
@keyframes fade { | |
from { | |
opacity: 1; | |
} | |
to { | |
opacity: 0; | |
} | |
} | |
.fade { | |
animation: fade 3s infinite alternate; | |
} | |
/* анімація 3: обертання */ | |
@keyframes rotate { | |
0% { | |
transform: rotate(0deg); | |
} | |
100% { | |
transform: rotate(360deg); | |
} | |
} | |
.rotate { | |
animation: rotate 4s linear infinite; | |
} | |
/* анімація 4: масштабування */ | |
@keyframes scale { | |
0%, | |
100% { | |
transform: scale(0.5); | |
} | |
50% { | |
transform: scale(1.5); | |
} | |
} | |
.scale { | |
animation: scale 2s infinite; | |
} | |
/* анімація 5: зміна кольору */ | |
@keyframes colorChange { | |
0% { | |
background-color: #4CAF50; | |
} | |
33% { | |
background-color: #FF5722; | |
} | |
66% { | |
background-color: #2196F3; | |
} | |
100% { | |
background-color: #4CAF50; | |
} | |
} | |
.color-change { | |
animation: colorChange 3s infinite; | |
} | |
/* анімація 6: рух по колу */ | |
@keyframes circleMove { | |
0% { | |
transform: rotate(0deg) translateX(40px) rotate(0deg); | |
} | |
100% { | |
transform: rotate(360deg) translateX(40px) rotate(-360deg); | |
} | |
} | |
.circular { | |
animation: circleMove 4s linear infinite; | |
background-color: #FF5722; | |
border-radius: 50%; | |
} | |
/* анімація 7: рух по прямокутнику */ | |
@keyframes rectangularMove { | |
0% { | |
transform: translate(0, 0); | |
} | |
25% { | |
transform: translate(40px, 0); | |
} | |
50% { | |
transform: translate(40px, 40px); | |
} | |
75% { | |
transform: translate(0, 40px); | |
} | |
100% { | |
transform: translate(0, 0); | |
} | |
} | |
.rectangular { | |
animation: rectangularMove 5s infinite; | |
} | |
/* анімація 8: зворотній прямокутник */ | |
.rectangular-reverse { | |
animation: rectangularMove 5s infinite reverse; | |
} | |
/* анімація 9: таймінг-функції */ | |
@keyframes moveRight { | |
from { | |
transform: translateX(0); | |
} | |
to { | |
transform: translateX(500px); | |
} | |
} | |
#div1, #div2, #div3, #div4, #div5 { | |
animation: moveRight 2s infinite alternate; | |
} | |
#div1 { | |
animation-timing-function: linear; | |
} | |
#div2 { | |
animation-timing-function: ease; | |
} | |
#div3 { | |
animation-timing-function: ease-in; | |
} | |
#div4 { | |
animation-timing-function: ease-out; | |
} | |
#div5 { | |
animation-timing-function: ease-in-out; | |
} | |
/* анімація 10: комбо */ | |
@keyframes epicCombined { | |
0% { | |
transform: translate(0, 0) scale(1) rotate(0deg); | |
background-color: #FF5733; | |
border-radius: 0; | |
box-shadow: 0 0 5px #FF5733; | |
} | |
20% { | |
transform: translate(50px, -50px) scale(1.2) rotate(90deg); | |
background-color: #33FF57; | |
border-radius: 25%; | |
box-shadow: 0 0 15px #33FF57; | |
} | |
40% { | |
transform: translate(100px, 50px) scale(0.8) rotate(180deg); | |
background-color: #3357FF; | |
border-radius: 50%; | |
box-shadow: 0 0 25px #3357FF; | |
} | |
60% { | |
transform: translate(-50px, 100px) scale(1.5) rotate(270deg); | |
background-color: #FF33A1; | |
border-radius: 75%; | |
box-shadow: 0 0 35px #FF33A1; | |
} | |
80% { | |
transform: translate(-100px, -50px) scale(1) rotate(360deg); | |
background-color: #FFD700; | |
border-radius: 25%; | |
box-shadow: 0 0 45px #FFD700; | |
} | |
100% { | |
transform: translate(0, 0) scale(1) rotate(0deg); | |
background-color: #FF5733; | |
border-radius: 0; | |
box-shadow: 0 0 5px #FF5733; | |
} | |
} | |
.combined { | |
animation: epicCombined 6s infinite alternate; | |
width: 100px; | |
height: 100px; | |
margin: auto; | |
} | |
</style> | |
</head> | |
<body> | |
<table> | |
<tr> | |
<td> | |
<div class="box bounce"></div> | |
<p>Пружина</p> | |
</td> | |
<td> | |
<div class="box fade"></div> | |
<p>Зникнення</p> | |
</td> | |
<td> | |
<div class="box rotate"></div> | |
<p>Обертання</p> | |
</td> | |
<td> | |
<div class="box scale"></div> | |
<p>Масштабування</p> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<div class="box color-change"></div> | |
<p>Зміна кольору</p> | |
</td> | |
<td> | |
<div class="box circular"></div> | |
<p>Рух по колу</p> | |
</td> | |
<td> | |
<div class="box rectangular"></div> | |
<p>Прямокутник</p> | |
</td> | |
<td> | |
<div class="box rectangular-reverse"></div> | |
<p>Зворотній рух</p> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<div id="div1" class="box"></div> | |
<p>Linear</p> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<div id="div2" class="box"></div> | |
<p>Ease</p> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<div id="div3" class="box"></div> | |
<p>Ease-in</p> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<div id="div4" class="box"></div> | |
<p>Ease-out</p> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<div id="div5" class="box"></div> | |
<p>Ease-in-out</p> | |
</td> | |
</tr> | |
<tr> | |
<td colspan="4"> | |
<div style="margin-bottom: 150px;" class="box combined"></div> | |
<p>Комбінована анімація</p> | |
</td> | |
</tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment