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

CSS के साथ रिस्पॉन्सिव टाइमलाइन कैसे बनाएं?


सीएसएस के साथ एक रिस्पॉन्सिव टाइमलाइन बनाने के लिए, कोड इस प्रकार है -

उदाहरण

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" event="width=device-width, initial-scale=1.0">
<style>
   * {
      box-sizing: border-box;
   }
   body {
      background-color: #9037f5;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif
   }
   h2{
      text-align: center;
   }
   .timeline {
      position: relative;
      max-width: 1200px;
      margin: 0 auto;
   }
   .timeline::after {
      content: " ";
      position: absolute;
      width: 6px;
      background-color: rgb(253, 203, 255);
      top: 0;
      bottom: 0;
      left: 50%;
      margin-left: -3px;
   }
   /* eventsContainer around event */
   .eventsContainer {
      padding: 10px 40px;
      position: relative;
      background-color: inherit;
      width: 50%;
   }
   .eventsContainer::after {
      content: " ";
      position: absolute;
      width: 25px;
      height: 25px;
      right: -17px;
      background-color: rgb(219, 255, 12);
      border: 4px dashed rgb(255, 0, 0);
      background-clip: content-box;
      top: 15px;
      z-index: 1;
   }
   .displayLeft {
      left: 0;
   }
   .displayRight {
      left: 50%;
   }
   .displayLeft::before {
      content: " ";
      height: 0;
      position: absolute;
      top: 22px;
      width: 0;
      z-index: 1;
      right: 30px;
      border: medium solid rgb(225, 246, 255);
      border-width: 10px 0 10px 10px;
      border-color: transparent transparent transparent white;
   }
   .displayRight::before {
      content: " ";
      height: 0;
      position: absolute;
      top: 22px;
      width: 0;
      z-index: 1;
      left: 30px;
      border: medium solid white;
      border-width: 10px 10px 10px 0;
      border-color: transparent white transparent transparent;
   }
   .displayRight::after {
      left: -16px;
   }
   .event {
      padding: 20px 30px;
      background-color: white;
      position: relative;
      border-radius: 6px;
   }
   @media screen and (max-width: 600px) {
      .timeline::after {
         left: 31px;
      }
      .eventsContainer {
         width: 100%;
         padding-left: 70px;
         padding-right: 25px;
      }
      .eventsContainer::before {
         left: 60px;
         border: medium solid white;
         border-width: 10px 10px 10px 0;
         border-color: transparent white transparent transparent;
      }
      .displayLeft::after, .displayRight::after {
         left: 15px;
      }
      .displayRight {
         left: 0%;
      }
   }
</style>
</head>
<body>
<div class="timeline">
<div class="eventsContainer displayLeft">
<div class="event">
<h2>2017</h2>
<h3>Donald Trump became the 45th president of US</h3>
</div>
</div>
<div class="eventsContainer displayRight">
<div class="event">
<h2>2016</h2>
<h3>Summer Olympics are held in rio de Janerio</h3>
</div>
</div>
<div class="eventsContainer displayLeft">
<div class="event">
<h2>2015</h2>
<h3>7.8 Magnitude Earthquake strikes nepal</h3>
</div>
</div>
</div>
</body>
</html>

आउटपुट

उपरोक्त कोड निम्न आउटपुट उत्पन्न करेगा -

CSS के साथ रिस्पॉन्सिव टाइमलाइन कैसे बनाएं?

स्क्रीन का आकार बदलने पर -

CSS के साथ रिस्पॉन्सिव टाइमलाइन कैसे बनाएं?


  1. कैसे सीएसएस के साथ उत्तरदायी प्रशंसापत्र बनाने के लिए? कैसे सीएसएस के साथ उत्तरदायी प्रशंसापत्र बनाने के लिए?

    सीएसएस के साथ प्रतिक्रियाशील प्रशंसापत्र बनाने के लिए, कोड इस प्रकार है - उदाहरण <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style>    body {       font-family: "

  1. CSS के साथ एक रेस्पॉन्सिव ब्लॉग लेआउट कैसे बनाएं? CSS के साथ एक रेस्पॉन्सिव ब्लॉग लेआउट कैसे बनाएं?

    सीएसएस के साथ प्रतिक्रियाशील ब्लॉग लेआउट बनाने के लिए, कोड इस प्रकार है - उदाहरण <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style>    * {       box-sizing: border-box

  1. CSS के साथ रिस्पॉन्सिव कॉलम कार्ड कैसे बनाएं? CSS के साथ रिस्पॉन्सिव कॉलम कार्ड कैसे बनाएं?

    सीएसएस के साथ रिस्पॉन्सिव कॉलम कार्ड बनाने के लिए, कोड इस प्रकार है - उदाहरण body { font-family:Segoe UI , ताहोमा, जिनेवा, वर्दाना, सेन्स-सेरिफ़; } * {बॉक्स-साइज़िंग:बॉर्डर-बॉक्स; } .कार्ड {रंग:सफेद; नाव छोड़ी; चौड़ाई:कैल्क (25% - 20px); पैडिंग:10px; सीमा-त्रिज्या:10px; मार्जिन:10px; ऊंचाई:200px; }