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

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

              
                <section class="timeline">
    <article class="timeline__item">
        <header>
            <h1 class="timeline__itemTitle">Timeline Item</h1>
        </header>
        <p class="timeline__itemDescription">Timeline description.</p>
    </article>
    <article class="timeline__item">
        <header>
            <h1 class="timeline__itemTitle">Timeline Item</h1>
        </header>
        <p class="timeline__itemDescription">Timeline description.</p>
    </article>
    <article class="timeline__item">
        <header>
            <h1 class="timeline__itemTitle">Timeline Item</h1>
        </header>
        <p class="timeline__itemDescription">Timeline description.</p>
    </article>
</section>
              
            
!

CSS

              
                // Re-usable variables.
$linearLineWidth: 0.6rem;
$itemGutterWidth: 2rem;
$itemVerticalSpacing: 4rem;
$customFontFamily: 'Open Sans', sans-serif;

%heading-copy-font {
    font-family: $customFontFamily;
    font-weight: 600;
}

%body-copy-font {
    font-family: $customFontFamily;
    font-weight: 300;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 62.5%;
}

html, body {
    margin: 0;
    paddng: 0;
}

// Overall container for items and the line.
.timeline {
    margin: 0 auto;
    padding: $itemVerticalSpacing 0 $itemVerticalSpacing 0;

    max-width: 600px;
    width: 90%;

    display: flex;
    flex-direction: column;
    position: relative;

    // Acts as the linear line in the timeline.
    &::after {
        display: block;
        content: '';

        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        transition: transform 1000ms;
        transform: translateX(-50%) translateY(-100%);
        z-index: -1;
        background-color: #000;
        width: $linearLineWidth;
    }

    // State class to trigger the timeline animation.
    &.timeline--show::after {
        transform: translateX(-50%) translateY(0);
    }
}

// Items that appear within the timeline.
.timeline__item {
    display: block;
    width: calc(50% - (#{$linearLineWidth} / 2));
    position: relative;

    // A circle that'll mark this items start on the line.
    &::before {
        content: '';
        display: block;
        position: absolute;
        top: 1.5rem;

        width: $linearLineWidth * 3;
        height: $linearLineWidth * 3;
        background: #FF0000;
        border-radius: 50%;
        transform: scale(0);

        // Applying the scaling animation when appropriate.
        .timeline--show & {
            animation: circleScaling 500ms 1500ms forwards;
        }
    }

    // Supplies spacing between items.
    &:not(:last-child) {
        margin-bottom: $itemVerticalSpacing
    }

    // Odd items will have their circle positioned to the left.
    &:nth-child(odd) {
        align-self: flex-end;
        padding-left: $itemGutterWidth;
        text-align: left;

        &::before {
            left: $linearLineWidth * -2;
        }
    }

    // Even items are positioned on the opposite side of odd items.
    // They will also have their circles aligned to the right.
    &:nth-child(even) {
        align-self: flex-start;
        padding-right: $itemGutterWidth;
        text-align: right;

        &::before {
            right: $linearLineWidth * -2;
        }
    }
}

// Main title within timeline items.
.timeline__itemTitle {
    @extend %heading-copy-font;
    font-size: 3.2rem;
    line-height: 1.5;
    margin: 0 0 1.2rem 0;
}

// Main body copy within timeline items.
.timeline__itemDescription {
    @extend %body-copy-font;
    font-size: 1.6rem;
    margin: 0;
}

// Titles / Descriptions will fade up when required.
.timeline__itemTitle,
.timeline__itemDescription {
    opacity: 0;
    transition: opacity 800ms;

    // Fades up the items when required.
    .timeline--show & {
        opacity: 1;
        transition-delay: 2500ms;
    }
}

// An animation to scale the circles up and down.
@keyframes circleScaling {
    0% {
        transform: scale(0);
    }
    80% {
        transform: scale(1.5);
    }
    100% {
        transform: scale(1);
    }
}
              
            
!

JS

              
                'use strict';
console.clear();

// When ready to paint, trigger the animation.
window.requestAnimationFrame(function() {
    document.querySelector('.timeline').classList.add('timeline--show');
});
              
            
!
999px

Console