ภาพเคลื่อนไหว CSS สามารถช่วยเราแปลงองค์ประกอบได้หลายวิธีโดยการรวม หมุน และแปล
ตัวอย่างต่อไปนี้แสดงให้เห็นว่าเราสามารถย้ายองค์ประกอบในเส้นทางวงกลมได้อย่างไร
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
div {
margin: 8%;
width: 35px;
height: 35px;
border-radius: 5px;
background: red;
animation: move 3s infinite linear;
}
@keyframes move {
0% {
transform: rotate(0deg) translateX(40px) rotate(0deg);
}
100% {
transform: rotate(360deg) translateX(40px) rotate(-360deg);
}
}
</style>
</head>
<body>
<div></div>
</body>
</html> ผลลัพธ์
สิ่งนี้จะให้ผลลัพธ์ดังต่อไปนี้ -
