Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

เคลื่อน HTML div ตามเส้นโค้ง

เพื่อเคลื่อน HTML div ตามเส้นโค้ง ใช้อย่างใดอย่างหนึ่ง:

  • CSS Transitions
  • JavaScript (jQuery)
  • HTML5 Canvas

ลอง JavaScript เพื่อทำงานในทุกเบราว์เซอร์

ใช้เมธอด animate() ทำ custom animation ของ CSS properties

Syntax:

selector.animate(params, [duration, easing, callback]);

คำอธิบายพารามิเตอร์:

  • params - map ของ CSS properties ที่ animation จะเคลื่อนไป
  • duration - optional ระยะเวลา animation
  • easing - optional easing function
  • callback - optional function เรียกเมื่อ animation จบ