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

CSS flex-direction प्रॉपर्टी - फ्लेक्स आइटम्स की दिशा

flex-direction प्रॉपर्टी फ्लेक्स कंटेनर के मेन एक्सिस (मुख्य अक्ष) को परिभाषित करती है, जिससे फ्लेक्स आइटम्स की दिशा निर्धारित होती है।

उदाहरण: वर्टिकल (कॉलम) दिशा

flex-direction: column से आइटम्स ऊपर से नीचे की ओर व्यवस्थित होते हैं।

<!DOCTYPE html>
<html>
<head>
  <style>
    .mycontainer {
      display: flex;
      flex-direction: column;
      background-color: orange;
      gap: 10px;
      padding: 10px;
    }
    .mycontainer > div {
      background-color: white;
      text-align: center;
      line-height: 40px;
      font-size: 25px;
      width: 100px;
      margin: 5px;
      align-self: center;
    }
  </style>
</head>
<body>
  <h1>क्विज़</h1>
  <div class="mycontainer">
    <div>Q1</div>
    <div>Q2</div>
    <div>Q3</div>
    <div>Q4</div>
    <div>Q5</div>
    <div>Q6</div>
  </div>
</body>
</html>

flex-direction के सभी मान

मानदिशामेन एक्सिस
rowबाएं से दाएं (डिफ़ॉल्ट)हॉरिजॉन्टल
row-reverseदाएं से बाएंहॉरिजॉन्टल
columnऊपर से नीचेवर्टिकल
column-reverseनीचे से ऊपरवर्टिकल

रिस्पॉन्सिव दिशा परिवर्तन

.container {
  display: flex;
  flex-direction: column;  /* मोबाइल पर वर्टिकल */
}
@media (min-width: 768px) {
  .container {
    flex-direction: row;  /* डेस्कटॉप पर हॉरिजॉन्टल */
  }
}

शॉर्टहैंड: flex-flow

flex-flow: column wrap;  /* flex-direction + flex-wrap */
  1. - CSS flex-shrink प्रॉपर्टी पर एनिमेशन करें

    फ्लेक्स-श्रिंक एनिमेशन flex-shrink प्रॉपर्टी पर CSS एनिमेशन लागू करें: उदाहरण <!DOCTYPE html> <html> <head> <style> .mycontainer { display: flex; background-color: orange; } .mycontainer > div { background-color: white; text-align: center;

  1. CSS में चाइल्ड सिलेक्टर्स CSS में चाइल्ड सिलेक्टर्स

    चाइल्ड सिलेक्टर CSS चाइल्ड सिलेक्टर का उपयोग किसी विशेष पैरेंट एलिमेंट के सभी चाइल्ड एलिमेंट्स को सिलेक्ट करने के लिए किया जाता है। सिंटैक्स element > element { /*declarations*/ } उदाहरण 1 <!DOCTYPE html> <html> <head> <style> * { padding: 5px; } article > div { border

  1. CSS में Background Attachment CSS में Background Attachment

    CSS में background-attachment प्रॉपर्टी का उपयोग व्यूपोर्ट के सापेक्ष पेज स्क्रॉल होने पर बैकग्राउंड इमेज की स्थिति निर्दिष्ट करने के लिए किया जाता है। इसके मान scroll, fixed और local हो सकते हैं। सिंटैक्स CSS background-attachment प्रॉपर्टी का सिंटैक्स निम्नलिखित है: Selector {    backgr