CSS flex-grow प्रॉपर्टी को एनिमेट करने के लिए @keyframes का उपयोग करें। यह फ्लेक्स आइटम के बढ़ने के अनुपात को समय के साथ बदलता है।
उदाहरण
<!DOCTYPE html> <html> <head> <style> .mycontainer { display: flex; background-color: red; align-content: space-between; } .mycontainer > div { background-color: white; text-align: center; line-height: 40px; font-size: 25px; width: 100px; margin: 5px; } div { animation: myanim 4s infinite; } @-webkit-keyframes myanim { 30% { flex-grow: 3; } } </style> </head> <body> <h1>Quiz</h1> <div class = "mycontainer"> <div style = "flex-grow: 1">A1</div> <div style = "flex-grow: 1">A2</div> <div style = "flex-grow: 20">A3</div> <div style = "flex-grow: 1">A4</div> <div style = "flex-grow: 1">A5</div> </div> </body> </html>
व्याख्या: सभी फ्लेक्स आइटम्स पर एनिमेशन लागू है। 30% कीफ्रेम पर flex-grow: 3 हो जाता है, जिससे आइटम्स उपलब्ध स्थान के अनुसार बढ़ते हैं। ध्यान दें कि इंलाइन स्टाइल में flex-grow: 20 वाला आइटम (A3) शुरुआत में सबसे बड़ा होता है।