Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h3> Linear timeline from left to right </h3>
<div id="horizontal-timeline" class="timeline horizontal reverse">
  <div class="block">
    <div class="square up">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <div class="circle">
      <p>2010</p>
    </div>
    <div class="link"></div>
    <div class="square down blank"></div>
  </div>
  <div class="block">
    <div class="square up blank"></div>
    <div class="circle activated">
      <p>2011</p>
    </div>
    <div class="link"></div>
    <div class="square down">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
  </div>
  <div class="block">
    <div class="square up">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <div class="circle">
      <p>2014</p>
    </div>
    <div class="link"></div>
    <div class="square down blank"></div>
  </div>
  <div class="block">
    <div class="square up blank"></div>
    <div class="circle">
      <p>2016</p>
    </div>
    <div class="link"></div>
    <div class="square down">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
  </div>

  <div class="block">
    <div class="square up">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <div class="circle">
      <p>2017</p>
    </div>
    <div class="link"></div>
    <div class="square down blank"></div>
  </div>
  <div id="end"></div>
</div>

<!-- Second linear timeline -->
<h3> Linear timeline from top to bottom </h3>
<div id="vertical-timeline" class="timeline vertical">
  <div class="block">
    <div class="square right">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <div class="circle">
      <p>2010</p>
    </div>
    <div class="link"></div>
    <div class="square left blank"></div>
  </div>

  <div class="block">
    <div class="square right blank"></div>
    <div class="circle">
      <p>2011</p>
    </div>
    <div class="link"></div>
    <div class="square left">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
  </div>

  <div class="block">
    <div class="square right">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <div class="circle activated">
      <p>2013</p>
    </div>
    <div class="link"></div>
    <div class="square left blank"></div>
  </div>

  <div class="block">
    <div class="square right blank"></div>
    <div class="circle">
      <p>2015</p>
    </div>
    <div class="link"></div>
    <div class="square left">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
  </div>

  <div class="block">
    <div class="square right">
      <h3>Main title</h3>
      <h4>date</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <div class="circle">
      <p>5</p>
    </div>
    <div class="link"></div>
    <div class="square left blank"></div>
  </div>
  <div id="end"></div>
</div>
              
            
!

CSS

              
                /* General code */
@import url(https://fonts.googleapis.com/css?family=Barlow+Condensed);
body {
  font-family: "Barlow Condensed";
  margin: auto;
  width: 100%;
  justify-content: center;
  display: flex;
  flex-direction: column;
  text-align: center;
  font-size: 16px;
}
button {
  width: 100px;
  margin: auto;
}
.timeline {
  display: flex;
  margin: auto;
  justify-content: center;
}
.timeline .circle {
  width: 30px;
  height: 30px;
  border-radius: 30px;
  background-color: #a8d0f7;
  margin: 0;
  padding: 2px;
  margin-left: -5px;
  z-index: 2;
  position: relative;
}
.timeline .circle:hover {
  cursor: pointer;
}
.timeline .circle p {
  text-align: center;
  margin: auto;
  line-height: 30px;
  color: #ffffff;
}
.timeline .link {
  z-index: 0;
  background-color: #a8d0f7;
  padding: 0;
}
.square {
  max-width: 250px;
  min-width: 100px;
  height: 115px;
  border-radius: 10px;
  background-color: rgb(176, 179, 204);
  z-index: 2;
  position: relative;
}
.square.blank {
  visibility: hidden;
}
#end {
  width: 0;
  height: 0;
}
.square h3,
.square h4 {
  margin: 0px 0px 0px 15px;
  text-align: left;
  font-size: 16px;
}
.square h3 {
  padding-top: 5px;
}
.square h4 {
  font-style: italic;
  font-weight: normal;
}

/* Linear timeline from left to right */
#horizontal-timeline {
  flex-direction: row;
  min-width: 1100px;
}
.horizontal .link {
  width: auto;
  height: 5px;
  margin-top: -15px;
  margin-left: 5px;
}
.horizontal .square {
  margin: 30px 0 20px -30px;
}
.horizontal .square p {
  padding: 0;
  margin: 0;
  width: 100%;
}
.square.up::after {
  margin: 12px 0px 0px 10px;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 20px solid rgb(176, 179, 204);
}

.square.down::after {
  margin: -108px 0 15px 15px;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 20px solid rgb(176, 179, 204);
}
.horizontal #end {
  margin: 175px 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 10px solid #a8d0f7;
}

/* Linear timeline from top to bottom */
.vertical .block {
  display: flex;
  flex-direction: row;
}
#vertical-timeline {
  flex-direction: column;
}
.vertical .link {
  width: 5px;
  height: 150px;
  margin-top: 0;
  margin-left: -20px;
}
.vertical .square {
  width: 250px;
  margin: 0px 25px 0px 35px;
}
.vertical .square p {
  padding: 0;
  margin: 0;
}
.vertical #end {
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid #a8d0f7;
  margin: auto;
  margin-left: 311px;
}
.square::after {
  content: " ";
  display: block;
  z-index: 0;
  width: 0px;
  height: 0px;
}
.square.left::after {
  margin: -70px 11px 0px -15px;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
  border-right: 20px solid rgb(176, 179, 204);
}
.square.right::after {
  margin: -75px 0px 0px 242px;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
  border-left: 20px solid rgb(176, 179, 204);
}

              
            
!

JS

              
                var vTimeline = document.getElementById("horizontal-timeline");
var hTimeline = document.getElementById("vertical-timeline");
activation(vTimeline);
activation(hTimeline);

function activation(timeline) {
  var divs = timeline.getElementsByTagName("div");
  for (var i = 0; i < divs.length; i++) {
    if (
      divs[i].classList.contains("circle") ||
      divs[i].classList.contains("link")
    ) {
      divs[i].style.background = "#05A5D1";
      if (divs[i].classList.contains("activated")) {
        break;
      }
    }
  }
}

              
            
!
999px

Console