ตัวอย่างการสร้างแอนิเมชันเปลี่ยน padding บน (padding-top) ของ element
ตัวอย่างโค้ด
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 350px;
height: 150px;
outline: 3px solid maroon;
animation: myanim 3s infinite;
}
@keyframes myanim {
30% {
padding-top: 60px;
}
}
</style>
</head>
<body>
<h1>CSS padding-top property</h1>
<div> </div>
</body>
</html>
คำอธิบาย: กล่องมี outline สีม่วงแดง เริ่มต้น padding-top = 0 ที่ 30% จะเพิ่มเป็น 60px เนื้อหาภายในจะถูกผลักลง
แนวทางที่ดีกว่า: ใช้ transform: translateY(60px) บน child element แทน