คุณสมบัติโหมดเติมภาพเคลื่อนไหว CSS
ตัวอย่าง
ให้องค์ประกอบ <div> รักษาค่าสไตล์จากคีย์เฟรมสุดท้ายเมื่อภาพเคลื่อนไหวสิ้นสุด:
div {
animation-fill-mode: forwards;
}
ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
คุณสมบัติanimation-fill-mode
ระบุสไตล์สำหรับองค์ประกอบเมื่อไม่ได้เล่นแอนิเมชั่น (ก่อนเริ่ม หลังสิ้นสุด หรือทั้งสองอย่าง)
ภาพเคลื่อนไหว CSS จะไม่ส่งผลต่อองค์ประกอบก่อนที่จะเล่นคีย์เฟรมแรกหรือหลังจากเล่นคีย์เฟรมสุดท้าย คุณสมบัติanimation-fill-mode
สามารถแทนที่พฤติกรรมนี้ได้
ค่าเริ่มต้น: | ไม่มี |
---|---|
รับการถ่ายทอด: | ไม่ |
เคลื่อนไหวได้: | ไม่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSS3 |
ไวยากรณ์ JavaScript: | วัตถุ .style.animationFillMode="forwards" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
ตัวเลขตามด้วย -webkit-, -moz- หรือ -o- ระบุเวอร์ชันแรกที่ทำงานกับคำนำหน้า
Property | |||||
---|---|---|---|---|---|
animation-fill-mode | 43.0 4.0 -webkit- |
10.0 | 16.0 5.0 -moz- |
9.0 4.0 -webkit- |
30.0 15.0 -webkit- 12.1 12.0 -o- |
ไวยากรณ์ CSS
animation-fill-mode: none|forwards|backwards|both|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description |
---|---|
none | Default value. Animation will not apply any styles to the element before or after it is executing |
forwards | The element will retain the style values that is set by the last keyframe (depends on animation-direction and animation-iteration-count) |
backwards | The element will get the style values that is set by the first keyframe (depends on animation-direction), and retain this during the animation-delay period |
both | The animation will follow the rules for both forwards and backwards, extending the animation properties in both directions |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ให้องค์ประกอบ <div> รับค่ารูปแบบที่กำหนดโดยคีย์เฟรมแรกก่อนที่ภาพเคลื่อนไหวจะเริ่มขึ้น (ในช่วงระยะเวลาหน่วงของภาพเคลื่อนไหว):
div {
animation-fill-mode: backwards;
}
ตัวอย่าง
ให้องค์ประกอบ <div> รับค่ารูปแบบที่กำหนดโดยคีย์เฟรมแรกก่อนที่ภาพเคลื่อนไหวจะเริ่มต้น และคงค่ารูปแบบจากคีย์เฟรมสุดท้ายเมื่อภาพเคลื่อนไหวสิ้นสุด:
div {
animation-fill-mode: both;
}
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: ภาพเคลื่อนไหว CSS
การอ้างอิง HTML DOM: คุณสมบัติ animationFillMode