Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                mixin timeline_wrapper(timeline_date, timeline_heading, timeline_detail, mod)
	if(mod!=="")
		.timeline-wrapper(class="timeline-wrapper--"+mod)
			// Timeline date
			.timeline-date-block.timeline-date-block--right.odd-year
				span.timeline-date= timeline_date
			// END: Timeline date
			// Timeline Content
			.timeline-content.timeline-content--right.odd-story
				h2.timeline-content__header= timeline_heading
				p.timeline-content__detail= timeline_detail
			// END: Timeline Content
	else
		.timeline-wrapper
			// Timeline date
			.timeline-date-block.even-year
				span.timeline-date= timeline_date
			// END: Timeline date
			// Timeline Content
			.timeline-content.even-story
				h2.timeline-content__header= timeline_heading
				p.timeline-content__detail= timeline_detail
			// END: Timeline Content


mixin timeline_block(block_id, block_type, timeline_date, timeline_heading, timeline_detail, timeline_wrapper_mod, mod)

	if(mod!==null)
		.story-year.clearfix(id= block_id class="story-year--"+mod+" "+block_type)
		
			if(timeline_wrapper_mod==="reverse")
				+timeline_wrapper(timeline_date, timeline_heading, timeline_detail, timeline_wrapper_mod)
				
			else
				+timeline_wrapper(timeline_date, timeline_heading, timeline_detail, "")
	else
		.story-year.clearfix(id= block_id class= block_type)
			+timeline_wrapper(timeline_date, timeline_heading, timeline_detail, "")





.doc-container
				// Intro part
				.intro-section
					.intro-content
						h1.intro-content__header Scroll down to see the timeline content load on scroll...
						.intro-content__icon
				// Timeline
				.timeline
					// Timeline block 1

					+timeline_block("even-year-1", "story-even", "1985", "Heading for this year", "Yo Yo watsaup dudes! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "", "first")
					// END: Timeline block 1
					
					// Timeline block 2
					+timeline_block("odd-year-1", "story-odd", "1930", "Heading for this year", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "reverse", "end")
					// END: Timeline block 2
					
					// Timeline block 3
					+timeline_block("even-year-2", "story-even", "1930", "Heading for this year", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "", "")
					// END: Timeline block 3
					
					// Timeline block 4
					+timeline_block("odd-year-2", "story-odd", "2000", "Heading for this year", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "reverse", "end")
					// END: Timeline block 4
					
					// Timeline block 5
					+timeline_block("even-year-3", "story-even", "2001", "Heading for this year", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "", "")
						// END: Timeline block 5
				// END: Timeline
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Lato");

/*-----------------------Color swatches-----------------------*/

$cyan: #00bcd4;
$yellow: #ffeb3b;

body{
  font-family: "Lato";
}

h1{
  font-size: 24px;
}

h2{
  font-weight: bold;
  font-size: 20px;
}

/*-----------------------END: Color swatches-----------------------*/

//Arrow animations
@keyframes anim{
	0%{
		opacity: 0;
		transform: translateY(0);
	}
	50%{
		opacity: 1;
	}
	100%{
		opacity: 0;
		transform: translateY(100%);
	}
}
//END: Arrow animations

//Intro section
.intro-section{
	height: 80vh;
	display: flex;
    justify-content: center;
	background: $cyan;
	color: white;

	.intro-content{
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		width: 50%;

		&__header{
			text-align: center;
		}

		&__icon{
			position: relative;
			height: 30px;
			width: 40px;
			margin-top: 40px;
			opacity: 0;
			transform: translateY(0);
			animation: anim 1s ease infinite;

			&:before, &:after{
				content: "";
				position: absolute;
				top: 0;
				height: 100%;
				width: 4px;
				background: white;
				border-radius: 30px;
			}

			&:before{
				left: 0px;
				transform: rotate(-45deg) translate(6px, 6px);
				transform-origin: center;
			}

			&:after{
				right: 0px;transform: rotate(45deg) translate(-6px, 6px);
				transform-origin: center;
			}
		}
	}
}
//END: Intro section

//timeline
.timeline{
    position: relative;
	background: $yellow;
	padding: 40px;
	overflow: hidden;

    &:before{
        position: absolute;
        content: "";
        background: #666;
        width: 4px;
		opacity: 0;
		height: 0%;
        left: 50%;
		top: 5%;
        -webkit-transform: translateX(-50%);
        transform: translateX(-50%);
        z-index: 0;
		transition: 1s ease;
    }

	&.active{
		&:before{
			opacity: 1;
			height: 90%;

			@media(min-width: 768px){
				height: 80%;
			}
		}
	}
}

.story-year{
    margin-top: 30px;
    position: relative;
    z-index: 1;

    @media(min-width: 768px){
        position: relative;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-pack: end;
        -webkit-justify-content: flex-end;
        -ms-flex-pack: end;
        justify-content: flex-end;
        margin-top: 60px;
    }

    @media(min-width: 992px){
        margin-top: 90px;
    }

    &--end{
        @media(min-width: 768px){
            -webkit-box-pack: start;
            -webkit-justify-content: flex-start;
            -ms-flex-pack: start;
            justify-content: flex-start;
        }
    }

    &--first{
        margin-top: 0;
    }
}

//timeline blocks

.timeline-wrapper{
    @media(min-width: 768px){
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        width: calc(50% + 45px);
        -webkit-box-pack: justify;
        -webkit-justify-content: space-between;
        -ms-flex-pack: justify;
        justify-content: space-between;
    }

    &--reverse{
        @media(min-width: 768px){
            -webkit-box-orient: horizontal;
            -webkit-box-direction: reverse;
            -webkit-flex-direction: row-reverse;
            -ms-flex-direction: row-reverse;
            flex-direction: row-reverse;
        }
    }

    .timeline-date-block{
        position: relative;
        z-index: 5;
        height: 90px;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-pack: center;
        -webkit-justify-content: center;
        -ms-flex-pack: center;
        justify-content: center;

        .timeline-date{
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-pack: center;
            -webkit-justify-content: center;
            -ms-flex-pack: center;
            justify-content: center;
            -webkit-box-align: center;
            -webkit-align-items: center;
            -ms-flex-align: center;
            align-items: center;
            height: 90px;
            width: 90px;
            border-radius: 50%;
            color: white;
			background: #212121;
            font-size: 18px;
            box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.2);
        }

        @media(min-width: 768px){
            display: inline-block;
        }

        &--right{
            @media(min-width: 768px){
                height: auto;
                display: -webkit-box;
                display: -webkit-flex;
                display: -ms-flexbox;
                display: flex;
                -webkit-box-pack: end;
                -webkit-justify-content: flex-end;
                -ms-flex-pack: end;
                justify-content: flex-end;
            }
        }
    }

    .timeline-content{
        position: relative;
        z-index: 2;
        background: white;
        padding: 30px;
        text-align: center;
        position: relative;
        margin-top: 25px;
        box-shadow: 0 2px 8px -1px rgba(0,0,0,0.1);

        &__detail{
            margin-top: 20px;
        }

        &:before{
            content: "";
            position: absolute;
            top: -15px;
            left: 50%;
            -webkit-transform: translateX(-50%);
            transform: translateX(-50%);
            width: 0;
            height: 0;
            border-left: 15px solid transparent;
            border-right: 15px solid transparent;
            border-bottom: 15px solid white;

            @media(min-width: 768px){
                top: 25px;
                left: -15px;
                -webkit-transform: none;
                transform: none;
                border-left: none;
                border-top: 15px solid transparent;
                border-right: 15px solid white;
                border-bottom: 15px solid transparent;
            }
        }

        @media(min-width: 768px){
            margin: 0;
            width: 70%;
            text-align: left;
            border-radius: 4px;
            box-shadow: 4px 3px 16px -4px rgba(0,0,0,0.1);
        }

        &--right{
            &:before{
                @media(min-width: 768px){
                    left: initial;
                    right: -15px;
                    -webkit-transform: none;
                    transform: none;
                    border-left: 15px solid white;
                    border-top: 15px solid transparent;
                    border-right: none;
                    border-bottom: 15px solid transparent;
                }
            }
        }
    }
}
//END: timeline blocks

/*----------------------Timeline section animation onscroll----------------------*/
$pos2: 60px;

.story-year{
    .even, .odd{

        &-year{
            -webkit-transform: scale(0.4);
            transform: scale(0.4);
            opacity: 0;

            &.active{
                -webkit-transform: scale(1);
                transform: scale(1);
                opacity: 1;
                -webkit-transition: 0.2s cubic-bezier(0, 0.65, 0.46, 0.85);
                transition: 0.2s cubic-bezier(0, 0.65, 0.46, 0.85);
            }
        }

        &-story{
            opacity: 0;

            &.active{
                opacity: 1;
                -webkit-transition: 0.6s 0.4s cubic-bezier(0, 0.65, 0.46, 0.85);
                transition: 0.6s 0.4s cubic-bezier(0, 0.65, 0.46, 0.85);
            }
        }
    }

    .even{
        &-year, &-story{
            position: relative;
        }

        &-story{
            top: -20px;

            &.active{
                top: 0;
            }

            @media(min-width: 768px){
                top: 0;
                right: $pos2;

                &.active{
                    right: 0;
                }
            }
        }
    }

    .odd{
        &-year, &-story{
            position: relative;
        }

        &-story{

            top: -20px;

            &.active{
                top: 0;
            }

            @media(min-width: 768px){
                top: 0;
                left: $pos2;

                &.active{
                    left: 0;
                }
            }
        }
    }
}
/*----------------------END: Timeline section animation onscroll----------------------*/

//END: timeline
              
            
!

JS

              
                $(document).ready(function(){
	$(window).scroll(function(){
    	var winTop = $(this).scrollTop();

		var story_eve = $(".story-even");
		var story_odd = $(".story-odd");
		var blockTop;
		var block;
		var blocktopDiff;
		var offset_2 = 650;

		var parent_container = $(".timeline");
		var container_top = parent_container.offset().top;
		var parent_scroll_diff = winTop - container_top + offset_2;

		console.log("parent scroll value: "+parent_scroll_diff);

		if(parent_scroll_diff>=100){
			parent_container.addClass("active");
		}

		story_eve.each(function(i){
			block_id = $(this).attr("id");
			blockTop = $("#"+block_id).offset().top;
			blocktopDiff = winTop - blockTop + offset_2;

			if(blocktopDiff>=100){
				$("#"+block_id).find(".even-year").addClass("active");
				$("#"+block_id).find(".even-story").addClass("active");
			}

		});

		story_odd.each(function(i){
			block_id = $(this).attr("id");
			blockTop = $("#"+block_id).offset().top;
			blocktopDiff = winTop - blockTop + offset_2;

			if(blocktopDiff>=100){
				$("#"+block_id).find(".odd-year").addClass("active");
				$("#"+block_id).find(".odd-story").addClass("active");
			}
		});
	});
});
              
            
!
999px

Console