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

              
                <header class="primary-header flex">
        <div>
            <img src="https://images.unsplash.com/photo-1640622308205-8ad9478c2386?ixlib=rb-1.2.1&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80" alt="logo" style="width: 150px; height: 100px;">
        </div>

        <button class="mobile-nav-toggle" aria-controls="primary-navigation" aria-expanded="false">
            <!-- <span class="sr-only">
                Menu    
            </span> -->
        </button>

        <nav>
            <ul id="primary-navigation"  data-visible="false" class="primary-navigation flex">
                <li class="active">
                    <a href="index.html">
                        <span aria-hidden="true">00 </span>Home
                    </a>
                <li>
                    <a href="blogs.html">
                        <span aria-hidden="true">01 </span>Blogs
                    </a>
                <li>
                    <a href="#">
                        <span aria-hidden="true">02 </span>Download
                    </a>
                <li>
                    <a href="contact.html">
                        <span aria-hidden="true">03 </span>Contact Us
                    </a>
            </ul>
        </nav>

    </header>

    <div>
        <img src="https://images.unsplash.com/photo-1640622308205-8ad9478c2386?ixlib=rb-1.2.1&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80" alt="" style="height:500px; width: 400px; object-fit: contain;">
    </div>

    <div id="animation"></div>
    <div id="desktopAnimation"></div>
              
            
!

CSS

              
                body {
    background-color: #000000;
    overflow-x: hidden;
   }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background-color: rgb(139, 138, 138);
}


.flex {
    display: flex;
    gap: var(--gap, 1rem);
}

.grid {
    display: grid;
    gap: var(--gap, 1rem);
}

/* Ptimary Header */
.logo {
    margin: 2rem;
}

.primary-header {
    align-items: center;
    justify-content: space-between;
}

.mobile-nav-toggle {
    display: none;
}

.primary-navigation {
    list-style: none;
    padding: 0;
    margin: 0;
    
    background: hsl(0, 0%, 0%, 0.5);
    backdrop-filter: blur(1rem);
}

@supports (backdrop-filter: blur(1rem)) {
    .primary-navigation {
        background: hsl(0, 0%, 100%, 0.1);
        backdrop-filter: blur(1rem);
    }
}


.primary-navigation a{
    color: white;
    text-decoration: none;
}

.primary-navigation a > [aria-hidden = "true"] {
    font-weight: 700;
    margin-block-end: 0.75em;
}

@media (max-width: 35em) {
    .primary-navigation {
        --gap: 2em;

        position: fixed;
        inset: 0 0 0 30%;

        flex-direction: column;
        padding: min(30vh, 10rem) 2em;

        transform: translateX(100%);
        transition: transform 350ms ease-out;
    }

    .primary-navigation[data-visible="true"] {
        transform: translateX(0%);
    }

    .mobile-nav-toggle {
        display: block;
        position: fixed;
        z-index: 100000;
        background-color: red;
        background-repeat: no-repeat;
        border: 0;
        width: 2rem;
        aspect-ratio: 1;
        top: 2rem;
        right: 2rem;
    }

    .mobile-nav-toggle[aria-expanded="true"] {
        background-image: url("hamburger-close.svg");
        background-color: transparent;
    }
}

/* Removes numbering on slightly bigger screens */
@media (min-width: 35em) and (max-width: 55em) {
    .primary-navigation a > span[aria-hidden = "true"] {
        display: none;
    }
}

@media (min-width: 35em) {
    .primary-navigation {
        --gap: clamp(1.5rem, 5vw, 3rem);
        padding-block: 2rem;
        padding-inline: clamp(3rem, 8vw, 10rem);
    }
}

/* Mobiles */
@media only screen and (max-width: 768px) { 
    #animation {
     width: 100vw;
     height: 90vh;
     padding-top: 5%;
    }

    #desktopAnimation {
        display: none;
    }
 }

/* Desktops */
@media only screen and (min-width: 768px) {
    #animation{
        display: none;
    }

    #desktopAnimation{
        width: 100vw;
        height: 100vh;
    }

}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger)

LottieScrollTrigger({
    target: "#animation",
    path: "https://assets4.lottiefiles.com/packages/lf20_nn8hue1i.json",
    speed: "medium",
    scrub: 2 // seconds it takes for the playhead to "catch up"
    // you can also add ANY ScrollTrigger values here too, like trigger, start, end, onEnter, onLeave, onUpdate, etc. See https://greensock.com/docs/v3/Plugins/ScrollTrigger
   });

LottieScrollTrigger({
    target: "#desktopAnimation",
    path: "https://assets4.lottiefiles.com/packages/lf20_nn8hue1i.json",
    speed: "slow",
    scrub: 2 // seconds it takes for the playhead to "catch up"
    // you can also add ANY ScrollTrigger values here too, like trigger, start, end, onEnter, onLeave, onUpdate, etc. See https://greensock.com/docs/v3/Plugins/ScrollTrigger
   });

   function LottieScrollTrigger(vars) {
	let playhead = {frame: 0},
		target = gsap.utils.toArray(vars.target)[0],
		speeds = {slow: "+=3000", medium: "+=1000", fast: "+=500"},
		st = {trigger: target, pin: true, start: "top top", end: speeds[vars.speed] || "+=1000", scrub: 1},
		animation = lottie.loadAnimation({
			container: target,
			renderer: vars.renderer || "svg",
			loop: false,
			autoplay: false,
			path: vars.path
		});
	for (let p in vars) { // let users override the ScrollTrigger defaults
		st[p] = vars[p];
	}
	animation.addEventListener("DOMLoaded", function() {
		gsap.to(playhead, {
			frame: animation.totalFrames - 1,
			ease: "none",
			onUpdate: () => animation.goToAndStop(playhead.frame, true),
			scrollTrigger: st
		});
    // in case there are any other ScrollTriggers on the page and the loading of this Lottie asset caused layout changes
    ScrollTrigger.sort();
    ScrollTrigger.refresh(); 
	});
  return animation;
}

// https://greensock.com/docs/v3/HelperFunctions#lottie

const primaryNav = document.querySelector(".primary-navigation");
const navToggle = document.querySelector(".mobile-nav-toggle");

navToggle.addEventListener('click',  () => {
    const visibility = primaryNav.getAttribute('data-visible')

    if (visibility === "false") {
        primaryNav.setAttribute("data-visible", true);
        navToggle.setAttribute('aria-expanded', true);
    } else if (visibility === "true") {
        primaryNav.setAttribute("data-visible", false);
        navToggle.setAttribute('aria-expanded', false);

    }
})
              
            
!
999px

Console