Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> HTML

HTML DOM Style animation प्रॉपर्टी


CSS हमें तत्वों के गुणों के संक्रमण को एनिमेट करने की अनुमति देता है। हम अपने वांछित स्टाइल को परिभाषित करने के लिए animation प्रॉपर्टी का उपयोग करते हैं। हम animation कीवर्ड का उपयोग करके animation-name, animation-duration, animation-iteration-count जैसे गुणों को संयोजित कर सकते हैं।

सिंटैक्स

animation प्रॉपर्टी का सिंटैक्स निम्नानुसार है:

object.style.animation = "name duration timingFunction delay iterationCount direction fillMode playState"

मान

निम्नलिखित मान हैं:

मानविवरण
animation-nameसेलेक्टर से बांधने के लिए कीफ्रेम नाम निर्दिष्ट करने के लिए।
animation-durationएनिमेशन की समय अवधि (सेकंड या मिलीसेकंड में) पूरा होने के लिए निर्दिष्ट करने के लिए।
animation-timing-functionएनिमेशन स्पीड कर्व निर्दिष्ट करने के लिए।
animation-delayएनिमेशन शुरू होने से पहले कुछ देरी निर्दिष्ट करने के लिए।
animation-iteration-countनिर्दिष्ट करने के लिए कि एनिमेशन कितनी बार खेला जाना चाहिए।
animation-directionयह इंगित करने के लिए कि एनिमेशन को वैकल्पिक या रिवर्स चक्र में चलना चाहिए या नहीं।
animation-fill-modeउन मानों को निर्दिष्ट करने के लिए जो एनिमेशन द्वारा उस समय के बाहर लागू किए जाते हैं जब यह निष्पादित हो रहा होता है।
animation-play-stateयह निर्दिष्ट करने के लिए कि एनिमेशन वर्तमान में रुका हुआ है या चल रहा है।
initialइस प्रॉपर्टी को उसके प्रारंभिक मान पर सेट करने के लिए।
inheritपैरेंट प्रॉपर्टी मान को विरासत में लेने के लिए।

उदाहरण

animation प्रॉपर्टी का उदाहरण देखते हैं:

<!DOCTYPE html> <html> <head> <style>    div {       width: 5px;       height: 15px;       background-color: limegreen;       animation: demo 4s infinite;    }    @keyframes demo {       from {width: 5px; background-color: limegreen;}       to {width: 400px; background-color: darkgreen;}    }    @keyframes demo1 {       from {height: 5px; background-color: limegreen;}       to {height: 400px; background-color: darkgreen;}    } </style> <script>    function changeAnimation() {       document.getElementById("DIV1").style.animation = "demo1 4s 2";    } </script> </head> <body> <button onclick="changeAnimation()">CHANGE ANIMATION</button> <p>Change the below animation by clicking the above button</p> <div id="DIV1"></div> </body> </html>

आउटपुट

यह निम्नलिखित आउटपुट उत्पन्न करेगा:

HTML DOM Style animation प्रॉपर्टी

CHANGE ANIMATION बटन पर क्लिक करने पर, एनिमेशन बदल जाएगा:

HTML DOM Style animation प्रॉपर्टी


  1. HTML DOM Style animationTimingFunction प्रॉपर्टी HTML DOM Style animationTimingFunction प्रॉपर्टी

    animationTimingFunction का उपयोग यह निर्दिष्ट करने के लिए किया जाता है कि एनिमेशन अपने चक्र के दौरान कैसे आगे बढ़ता है। यह एनिमेशन के लिए स्पीड कर्व सेट या रिटर्न करके ऐसा करता है। स्पीड कर्व परिभाषित करता है कि संक्रमण कितने सहज होंगे, यह निर्दिष्ट करके कि एनिमेशन को एक स्थिति से दूसरी स्थिति में

  1. HTML DOM Style animationPlayState प्रॉपर्टी HTML DOM Style animationPlayState प्रॉपर्टी

    animationPlayState प्रॉपर्टी का उपयोग एनिमेशन की स्थिति को सेट या प्राप्त करने के लिए किया जाता है कि यह चल रहा है या रुका हुआ है। यह एनिमेशन को टॉगल करने में उपयोगी है। सिंटैक्स animationPlayState प्रॉपर्टी सेट करने के लिए सिंटैक्स निम्नलिखित है: object.style.animationPlayState = running|paused|in

  1. HTML DOM Style animationIterationCount प्रॉपर्टी HTML DOM Style animationIterationCount प्रॉपर्टी

    animationIterationCount प्रॉपर्टी का उपयोग एनिमेशन के चलने की संख्या को सेट या प्राप्त करने के लिए किया जाता है। सिंटैक्स animationIterationCount प्रॉपर्टी सेट करने के लिए सिंटैक्स निम्नलिखित है: object.style.animationIterationCount = number|infinite|initial|inherit मान निम्नलिखित मान हैं: क्रमां