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 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

              
                nav.c-nav
    a.c-nav__logo.js-scroll-to-section(href="#") Logo
    ul.c-nav__list.js-nav
        li: a.c-nav__link.js-scroll-to-section(href="#intro")
            span.c-nav__link-progress
            span.c-nav__link-label Intro
        li: a.c-nav__link.js-scroll-to-section(href="#about")
            span.c-nav__link-progress
            span.c-nav__link-label About
        li: a.c-nav__link.js-scroll-to-section(href="#offer")
            span.c-nav__link-progress
            span.c-nav__link-label Offer
        li: a.c-nav__link.js-scroll-to-section(href="#contact")
            span.c-nav__link-progress
            span.c-nav__link-label Contact

main.c-main.js-sections
    section.c-section#intro
        h1 Intro
        p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Asperiores modi odit blanditiis aperiam obcaecati voluptatibus temporibus consequuntur animi ea odio earum inventore tempore quae sit assumenda, ullam, nisi ad nam cum? Ullam, porro illo harum cum. Neque quis deleniti vitae maiores laborum. Quisquam doloribus nobis assumenda, suscipit molestias eveniet quam obcaecati ipsa voluptate itaque? Nobis nostrum, harum eligendi minus similique consequatur odit eos, ullam sit iusto molestias animi autem. Ullam quis voluptas et sit esse repellat officia ipsa sint odit mollitia unde, reiciendis pariatur nam sequi a nemo est porro neque. Iste iusto suscipit provident nulla maxime, expedita, molestias possimus?
        p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Asperiores modi odit blanditiis aperiam obcaecati voluptatibus temporibus consequuntur animi ea odio earum inventore tempore quae sit assumenda, ullam, nisi ad nam cum? Ullam, porro illo harum cum. Neque quis deleniti vitae maiores laborum. Quisquam doloribus nobis assumenda, suscipit molestias eveniet quam obcaecati ipsa voluptate itaque? Nobis nostrum, harum eligendi minus similique consequatur odit eos, ullam sit iusto molestias animi autem. Ullam quis voluptas et sit esse repellat officia ipsa sint odit mollitia unde, reiciendis pariatur nam sequi a nemo est porro neque. Iste iusto suscipit provident nulla maxime, expedita, molestias possimus?
        p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Asperiores modi odit blanditiis aperiam obcaecati voluptatibus temporibus consequuntur animi ea odio earum inventore tempore quae sit assumenda, ullam, nisi ad nam cum? Ullam, porro illo harum cum. Neque quis deleniti vitae maiores laborum. Quisquam doloribus nobis assumenda, suscipit molestias eveniet quam obcaecati ipsa voluptate itaque? Nobis nostrum, harum eligendi minus similique consequatur odit eos, ullam sit iusto molestias animi autem. Ullam quis voluptas et sit esse repellat officia ipsa sint odit mollitia unde, reiciendis pariatur nam sequi a nemo est porro neque. Iste iusto suscipit provident nulla maxime, expedita, molestias possimus?
    section.c-section#about
        h1 About
        p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum ex nemo dicta aperiam soluta laboriosam atque ab commodi similique, sunt delectus! Voluptates id laborum similique, dicta quasi consequatur adipisci illum quos perferendis nemo. Tenetur, et ducimus obcaecati pariatur culpa perferendis consectetur. Nesciunt, similique totam. Cum unde hic placeat tempora cumque blanditiis rem corporis libero voluptatum autem accusamus vel sunt earum esse, magnam a vero officiis ea, voluptatibus molestiae architecto quia similique, sint harum. Maxime, impedit unde ducimus. In fugit ea nostrum iure, laudantium, consequuntur eligendi architecto illo doloremque nulla accusamus blanditiis placeat voluptatum amet culpa quae odio suscipit dolorem omnis.
    section.c-section#offer
        h1 Offer
        p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet quam error rem tempora quas, vel veniam minus dicta, quisquam reprehenderit expedita cupiditate sequi vitae iure aspernatur nam ea repellat facilis dolore ipsam quo quis. Distinctio incidunt nulla blanditiis necessitatibus explicabo nobis atque, beatae sed officia illo impedit, minus porro aspernatur voluptates eaque adipisci eveniet ipsa libero hic dicta, iste, excepturi pariatur aliquam! Deleniti nulla vero eaque! Eligendi id voluptatum, dolorum sed placeat accusamus laudantium odit repudiandae vero commodi minus a, quisquam aut aliquam incidunt quibusdam voluptate repellat, tempore ea nobis eveniet. Rerum, reiciendis quasi voluptas, eligendi perferendis cum dolores maiores!
    section.c-section#contact
        h1 Contact
        p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorum similique consequatur, sequi voluptates id explicabo odit aliquam, delectus nemo quasi aliquid quo sit. Et voluptates beatae dolores repellat ex soluta eius similique numquam pariatur est facilis nulla iusto, quod voluptatibus eveniet voluptatum velit tempore odio vel sed voluptas natus, explicabo obcaecati. Aliquam quia ab animi, velit, omnis culpa fugit consequatur ipsam iusto ullam libero voluptate impedit suscipit nesciunt expedita ratione molestiae placeat. Debitis corrupti eveniet possimus tenetur facere error, perferendis vel, molestiae repellat odio eum eos ea labore dolor. Commodi minima quas vitae quod deleniti incidunt expedita molestiae possimus quisquam!

footer.c-footer
              
            
!

CSS

              
                $color: #673ab7
$color--dark: darken($color, 10%)
$color--darker: darken($color, 15%)

// $color: #222
// $color--dark: #111
// $color--darker: #000

body
    font: 16px Roboto, Arial, sans-serif

*
    box-sizing: border-box

a
    color: inherit
    text-decoration: none

.c-nav
    display: flex
    align-items: center
    width: 100%
    position: fixed
    top: 0
    left: 0
    background: $color

    &__logo
        padding-right: rem(30px)
        padding-left: rem(30px)
        font-weight: bold
        font-size: rem(22px)
        line-height: rem(60px)
        color: white

    &__list
        flex-basis: 60%
        display: flex
        margin-left: auto
        background: $color--darker

        li
            flex: 1

    &__link
        display: block
        position: relative
        padding-right: rem(30px)
        padding-left: rem(30px)
        line-height: rem(60px)
        text-align: center
        color: rgba(white, .5)
        transition: .4s

        &.is-visited
            background: $color--dark

        &.is-active
            color: white
            background: $color--dark

    &__link-progress
        width: 0%
        height: 100%
        position: absolute
        top: 0
        left: 0
        background: $color
        pointer-events: none

    &__link-label
        position: relative
        pointer-events: none

.c-main
    padding-top: rem(60px)

.c-section
    padding: rem(80px) 15%

    &:nth-of-type(even)
        background-color: #f5f5f5

    h1
        margin-bottom: em(25px, 36px)
        font-size: rem(33px)
        color: #333

    p
        line-height: 1.7
        color: #888

.c-footer
    height: calc(100vh + 60px)
    background: #111

              
            
!

JS

              
                const links = $$(".js-nav a");
const sections = $$(".js-sections > section");
const navbarHeight = $(".js-nav").offsetHeight;

const elements = links.map(link => ({
    link,
    section: sections.find(s => s.id === link.getAttribute("href").slice(1)),
    progressBar: link.children[0]
}));

const updateSectionBCR = () =>
    elements.forEach(el => {
        const bcr = el.section.getBoundingClientRect();
        el.top = bcr.top + scrollY;
        el.height = bcr.height;
    });

const updateProgress = () =>
    elements.forEach(el => {
        const y = scrollY - el.top + navbarHeight + 1;
        const h = el.height;

        let percent = y / h * 100;
        percent = Math.max(Math.min(percent, 100), 0);

        el.progressBar.style.width = `${percent}%`;

        const isVisited = percent === 100;
        el.link.classList[isVisited ? "add" : "remove"]("is-visited");

        const isActive = percent > 0 && percent !== 100;
        el.link.classList[isActive ? "add" : "remove"]("is-active");
    });

updateSectionBCR();
updateProgress();

window.on("scroll", updateProgress);

window.on(
    "resize",
    _.debounce(() => {
        updateSectionBCR();
        updateProgress();
    }, 500)
);

              
            
!
999px

Console