css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              Building a Vertical Timeline With CSS and a Touch of JavaScript
original by <a href="https://webdesign.tutsplus.com/tutorials/building-a-vertical-timeline-with-css-and-a-touch-of-javascript--cms-26528"> George Martsoukos on 24 May 2016</a>
Original codepen
<a href="https://codepen.io/tutsplus/details/QNeJgR"> is here </a>
<br>
scroll to view effetcs
<div class="timeline2">
		  <ul>
			<li>
			  <div>
				<time>1934</time> At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium
			  </div>
				<span class="time">
					<span>JUN, 17<sup>th</sup></span>
					<span>12:00 AM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>1937</time> Proin quam velit, efficitur vel neque vitae, rhoncus commodo mi. Suspendisse finibus mauris et bibendum molestie. Aenean ex augue, varius et pulvinar in, pretium non nisi.
			  </div>
				<span class="time">
					<span>JUN, 29<sup>th</sup></span>
					<span>11:36 AM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>1940</time> Proin iaculis, nibh eget efficitur varius, libero tellus porta dolor, at pulvinar tortor ex eget ligula. Integer eu dapibus arcu, sit amet sollicitudin eros.
			  </div>
				<span class="time">
					<span>Jul, 1<sup>st</sup></span>
					<span>10:30 AM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>1943</time> In mattis elit vitae odio posuere, nec maximus massa varius. Suspendisse varius volutpat mattis. Vestibulum id magna est.
			  </div>
				<span class="time">
					<span>Jul, 2<sup>nd</sup></span>
					<span>12:30 PM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>1946</time> In mattis elit vitae odio posuere, nec maximus massa varius. Suspendisse varius volutpat mattis. Vestibulum id magna est.
			  </div>
				<span class="time">
					<span>Jul, 3<sup>rd</sup></span>
					<span>01:30 PM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>1956</time> In mattis elit vitae odio posuere, nec maximus massa varius. Suspendisse varius volutpat mattis. Vestibulum id magna est.
			  </div>
				<span class="time">
					<span>Jul, 4<sup>th</sup></span>
					<span>01:30 PM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>1957</time> In mattis elit vitae odio posuere, nec maximus massa varius. Suspendisse varius volutpat mattis. Vestibulum id magna est.
			  </div>
				<span class="time">
					<span>Jul, 5<sup>th</sup></span>
					<span>01:30 PM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>1967</time> Aenean condimentum odio a bibendum rhoncus. Ut mauris felis, volutpat eget porta faucibus, euismod quis ante.
			  </div>
				<span class="time">
					<span>Jul, 6<sup>th</sup></span>
					<span>01:30 PM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>1977</time> Vestibulum porttitor lorem sed pharetra dignissim. Nulla maximus, dui a tristique iaculis, quam dolor convallis enim, non dignissim ligula ipsum a turpis.
			  </div>
				<span class="time">
					<span>Jul, 7<sup>th</sup></span>
					<span>01:30 PM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>1985</time> In mattis elit vitae odio posuere, nec maximus massa varius. Suspendisse varius volutpat mattis. Vestibulum id magna est.
			  </div>
				<span class="time">
					<span>Aug, 1<sup>st</sup></span>
					<span>01:30 PM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>2000</time> In mattis elit vitae odio posuere, nec maximus massa varius. Suspendisse varius volutpat mattis. Vestibulum id magna est.
			  </div>
				<span class="time">
					<span>Aug, 2<sup>nd</sup></span>
					<span>01:30 PM</span>
				</span>
			</li>
			<li>
			  <div>
				<time>2005</time> In mattis elit vitae odio posuere, nec maximus massa varius. Suspendisse varius volutpat mattis. Vestibulum id magna est.
			  </div>
				<span class="time">
					<span>Aug, 3<sup>rd</sup></span>
					<span>01:30 PM</span>
				</span>
			</li>
		  </ul>
		</div>
	
            
          
!
            
              /* TIMELINE
			–––––––––––––––––––––––––––––––––––––––––––––––––– */
			.timeline2 {
				overflow-y: scroll;
				overflow-x: hidden;
				height: 550px;
				top: calc(100%-600px);
				position: relative;
				scroll-behavior:  smooth ;
				 
			}
			.timeline2   *, .timeline2   *::before, .timeline2   *::after { 
				font: normal 16px/1.5 "Helvetica Neue", sans-serif;
				color: #fff;
				margin: 0;
				padding: 0;
				box-sizing: border-box;
			}
			.timeline2::-webkit-scrollbar {
				width: 12px;
				background-color: #F5F5F5;
			}
			 
			.timeline2::-webkit-scrollbar-track {
				-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
				border-radius: 10px;
				background-color: #F5F5F5;
			}
			 
			.timeline2::-webkit-scrollbar-thumb {
				border-radius: 10px;
				-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
				background-color: #555;
			}
			 
			.timeline2 ul {
			  background: #456990;
			  /* padding: 50px 0; */
			}

			.timeline2 ul li {
			  list-style-type: none;
			  position: relative;
			      width: 2px;/* width: 6px; */
			  margin: 0 auto;
				padding-top: 10px;/* 50px; */
				padding-bottom: 10px;/* padding-bottom: 20px; = center padding-bottom: 10px; = center */
			 background: #fff; /* background: black;  */
			  
				border-left: 3px double white;
				
			}

			 
			.timeline2 ul li::after {
			  content: '';
			  position: absolute;
			  left: 50%;
			  top: 30px; /* bottom: 0;  bottom: 50%;=center top: 30px;=top  */ 
			  transform: translateX(-55%);/* transform: translateX(-50%); */
			  -webkit-transform: translateX(-55%);
			  width: 30px;
			  height: 30px;
			  border-radius: 50%;
			  background: inherit;
			  border: 2px solid #03A9F4;
			}

			.timeline2 ul li div {
			  position: relative;
			  bottom: 0;
			  width: 400px;
			  padding: 15px;
			  background: #03A9F4;
			  
			}

			.timeline2 ul li div::before {
			  content: '';
			  position: absolute;
			  top: 20px; /* bottom: 7px; bottom: 50%;=center top: 20px;=top */
			  
			  width: 0;
			  height: 0;
			  border-style: solid;
			}

			.timeline2 ul li:nth-child(odd) div {
			  left: 45px;
			}

			.timeline2 ul li:nth-child(odd) div::before {
			  left: -15px;
				border-width: 16px 16px 16px 0;/* border-width: 8px 16px 8px 0; */
			  border-color: transparent #03A9F4 transparent transparent;
			}

			.timeline2 ul li:nth-child(even) div {
			  left: -439px;
			}

			.timeline2 ul li:nth-child(even) div::before {
			  right: -15px;
			  	border-width: 16px 0 16px 16px; /* border-width: 8px 0 8px 16px; */
			  border-color: transparent transparent transparent #03A9F4;
			}
			
			
			.timeline2 ul li:nth-child(odd) .time {
				position: absolute;
				top: 20px;
				left: -100px;
				width: 90px;
			}
			.timeline2 ul li:nth-child(even) .time {
				position: absolute;
				top: 20px;
				right: -120px;
				width: 90px;
			}
			
			
			.timeline2 time {
			  display: block;
			  font-size: 1.2rem;
			  font-weight: bold;
			  margin-bottom: 8px;
			}


			/* EFFECTS
			–––––––––––––––––––––––––––––––––––––––––––––––––– */

			.timeline2 ul li::after {
				transition: background .5s ease-in-out;
				-webkit-transition: background .5s ease-in-out;
			}

			.timeline2 ul li.in-view::after {
			  background: #03A9F4;
			  border: 2px solid white;
			}

			.timeline2 ul li div {
			  visibility: hidden;
			  opacity: 0;
				transition: all .5s ease-in-out;
				-webkit-transition: all .5s ease-in-out;
			}

			.timeline2 ul li:nth-child(odd) div {
				transform: translate3d(200px, 0, 0);
				-webkit-transform: translate(200px, 0, 0);
			}

			.timeline2 ul li:nth-child(even) div {
				transform: translate3d(-200px, 0, 0);
				-webkit-transform: translate(-200px, 0, 0);
			}

			.timeline2 ul li.in-view div {
				transform: none;
				-webkit-transform: none;
			  visibility: visible;
			  opacity: 1;
			  /* disabled when arrow is on top position
			  border-radius: 10px;
			  */
			}
			
			.timeline2 ul li  .time {
				transition: all .5s ease-in-out;
				-webkit-transition: all .5s ease-in-out;
				transform: rotate(-90deg);
				-webkit-transform:rotate(270deg);
			}
			.timeline2 ul li.in-view  .time {
				transform: rotate(0deg);
				-webkit-transform:rotate(0deg);
			}

			/* GENERAL MEDIA QUERIES
			–––––––––––––––––––––––––––––––––––––––––––––––––– */

			@media screen and (max-width: 900px) {
			  .timeline2 ul li div {
				width: 250px;
			  }
			  .timeline2 ul li:nth-child(even) div {
				left: -289px;
				/*250+45-6*/
			  }
			}

			@media screen and (max-width: 600px) {
			  .timeline2 ul li {
				margin-left: 20px;
			  }
			  .timeline2 ul li div {
				width: calc(100vw - 120px);
			  }
			  .timeline2 ul li:nth-child(even) div {
				left: 45px;
			  }
			  .timeline2 ul li:nth-child(even) div::before {
				left: -15px;
				border-width: 16px 16px 16px 0; /* border-width: 8px 16px 8px 0;  */
				border-color: transparent #03A9F4 transparent transparent;
			  }
			  
				
				.timeline2 ul li:nth-child(odd) .time {
					position: absolute;
					top: 60px;
					left: -23px;
					width: 90px;
					/*
					transform: rotate(-90deg);
					-webkit-transform:rotate(270deg);
					*/
					transform: rotate(0deg);
					-webkit-transform:rotate(0deg);
				}
				.timeline2 ul li:nth-child(even) .time {
					position: absolute;
					top: 60px;
					right: -67px;
					width: 90px;
					/*
					transform: rotate(-90deg);
					-webkit-transform:rotate(270deg);
					*/
					transform: rotate(0deg);
					-webkit-transform:rotate(0deg);
				}
				.timeline2 ul li.in-view:nth-child(odd) .time {
					transform: rotate(-90deg);
					-webkit-transform:rotate(270deg);					 
				}
				.timeline2 ul li.in-view:nth-child(even) .time {
					transform: rotate(-90deg);
					-webkit-transform:rotate(270deg);
				}
			  
			}
            
          
!
            
              (function() {
			 
			  'use strict';

			  // define variables
			  var timelines= document.querySelectorAll('.timeline2');
			   
				function debounce(func, wait, immediate) {
					var timeout;
					return function() {
						var context = this, args = arguments;
						var later = function() {
							timeout = null;
							if (!immediate) func.apply(context, args);
						};
						var callNow = immediate && !timeout;
						clearTimeout(timeout);
						timeout = setTimeout(later, wait);
						if (callNow) func.apply(context, args);
					};
				}
				function callbackFunc() {
					  var h,timeline, li,rect,parent_rect,i,items;
					for(h=0;h<timelines.length;h++){
						  timeline=timelines[h];
							parent_rect=timeline.getBoundingClientRect();
						   items = timeline.querySelectorAll(".timeline2 li");
						for (  i = 0; i < items.length; i++) {
							/*
						  if (isElementInViewport(items[i])) {
							items[i].classList.add("in-view");				   
						  }
						  */
							li=items[i];
							rect = li.getBoundingClientRect();  
							 
							if( (rect.bottom<=(parent_rect.top+(rect.height/2) ) ) || (rect.top >=(parent_rect.bottom-(rect.height/2)) ) ){
								//debugger;
								//li.style['background']='red';
								li.classList.remove("in-view");
								
							}else{
								//li.style['background']='white';
								li.classList.add("in-view");
							}
							 
						}
					}
				}
				var updateLayout =debounce(function(e) {

					// Does all the layout updating here
					callbackFunc();
					
				}, 500); // Maximum run of once per 500 milliseconds

				// listen for events
				window.addEventListener("load", callbackFunc);
				window.addEventListener("resize", updateLayout);
				window.addEventListener("scroll", callbackFunc);
				for(var h=0;h<timelines.length;h++){
						var  timeline=timelines[h];
					timeline.addEventListener("scroll",callbackFunc );
				}
				
			 })();
				
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console