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

              
                <html>
<head>

    <title>Dynamic header</title>

</head>
<body>

    <header>
        <h1>Dynamic header</h1>
        <nav>
            <li><a>Home</a></li>
            <li><a>Go away</a></li>
            <li><a>Stay here</a></li>
            <li><a>Don't listen to me</a></li>
        </nav>
    </header>
    <div class="wrapper">
        <section>Laborum Sugar Ray Toy Story Doc Martens Gordon Bombay. Cassette tape consectetur Game Boy Color cable modem. Home Alone hoop earrings eiusmod the Matrix Christina Aguilera. Courtney Love bop it bye bye bye Tupac Shakur anim, Cory Matthews the more you know Wayne Gretzky ullamco. Culpa pop punk valley girl Dawson’s Creek chat rooms. Frosted tips OJ Simpson Smarter Child Rush Hour Britney Spears. Will Smith kicks valley girl Space Jam Napster, digital pets chillax portable CD players Generation Y pixie cut. I will always love you Teenage Mutant Ninja Turtles Toyota Supra sunt skate tees. Mad props Korn Destiny’s Child West Wing Ross and Rachel VCR, Enrique Iglesias New Kids on the Block Chandler Bing adipiscing Topanga non. Scrolling text Topanga Tamagotchi sit Speed. Chillax Enrique Iglesias oversized sweaters cutoff jeans. Miss Cleo aliquip Seattle Supersonics Rachel haircut Barbie Stretch Armstrong. Gatorade Ken Griffey Jr Razor scooter highlights Sega Genesis. Garth Brooks Generation Y how do you like them apples Pokémon personal computer millenials. Pontiac Trans Sport leotards esse Central Perk Nickelodeon, Desert Storm do ut eu amet. Furby berry lips Topanga wearing your cap backwards Chronic. Natalie Imbruglia Puff Daddy flat tops Sugar Ray cable modem MTV, Dennis Rodman Green Day Baywatch flannel dope bare midriffs. Apollo 13 Steve Urkel khaki Ut dolor, sit Blur highlights cassette tape.</section>
        <section>Trucks overalls with one strap undone Big Lebowski Oasis Toni Braxton Blockbuster video. Tae Bo consequat pagers Stretch Armstrong Royal Stewart tartan Wonderwall. Razor scooter neon colors Jim Carrey smells like teen spirit VHS tapes Oakleys. Et mad props Boyz II Men Reebok Pumps, millenials cutoff jeans sideburns pariatur Pulp Fiction. AC Slater screening phone calls wild cherry Pepsi Topanga ain’t no thang. Carpenter pants choker necklace Ross and Rachel da bomb Ford Taurus, Sugar Ray Union Jack Aerosmith Doug khaki. Dotcom bubble millenials buddy list Hootie and the Blowfish Doc Martens et. Fresh Prince of Bel-Air bike caps turquoise Hotmail Kurt Cobain, culpa Free Willy Lion King Wonderwall minim neon colors. Men in Black laborum Umbro shorts parting your hair down the middle Discman. Smells like teen spirit adipiscing leopard print yo as if. Rachel Green scrunchies Speed in.Stretch Armstrong the Truman Show Tommy Hilfiger Windows 95. Generation Y trainers Macaulay Culkin Hulk Hogan did I do that. Wayne Gretzky gak Tupac Shakur Rachel Green. Rayon shirts Independence Day Vanilla Ice as if Tamagotchi eu. Mazda MPV sideburns overalls with one strap undone Super Nintendo, TRL scrolling text Pulp Fiction Wesley Snipes.Tamagotchi nostrud Warheads gotta have my Pops, Air Jordans George Michael mood rings Super Nintendo Hush Puppies wild cherry Pepsi. </section>
        <section>Floppy disk Ford Explorer gangsta’s paradise dotcom bubble. Aliquip khaki Garth Brooks Kurt Cobain enim, DJ Jazzy Jeff qui hi-top fade Backstreet Boys Natalie Imbruglia Blur. Dolore Topanga Apollo 13 polo shirts with popped collars Dennis Rodman crop tops. Tommy Hilfiger Wayne’s World the Phantom Menace you’ve got mail instant messaging Chronic. Ipsum Super Mario World accent braids tying your sweater around your waist. Qui got milk Doc Martens anim Blur, Tommy Hilfiger pop punk sup Windows 95. Dawg rollerblades bike caps overalls with one strap undone Speed videocassette, dolore butterfly clips New Kids on the Block Apollo 13 home skillet. Boy Meets World Super Nintendo this is your brain on drugs crib ut SkiFree. Veniam consequat West Wing turquoise esse.</section>
    </div>

</body>
</html>
              
            
!

CSS

              
                *{
    box-sizing: border-box;
}

body{
    margin: 0;
    font-size: 16px;
    padding-top: 330px;
    transition: padding-top .5s ease;
    -webkit-transition: padding-top .5s ease;
    -moz-transition: padding-top .5s ease;
    -ms-transition: padding-top .5s ease;
    -o-transition: padding-top .5s ease;
}

header{
    width: 100%;
    height: 300px;
    background-color: #b056ff;
    text-align: center;
    position: fixed;
    top:0;
    overflow: hidden;
    transition: all .5s ease;
    -webkit-transition: all .5s ease;
    -moz-transition: all .5s ease;
    -ms-transition: all .5s ease;
    -o-transition: all .5s ease;

}

header h1{
    font-size: 42px;
    color: #fff;
    line-height: 230px;
    text-transform: uppercase;
    font-weight: 100;
    transition: all .5s ease;
    -webkit-transition: all .5s ease;
    -moz-transition: all .5s ease;
    -ms-transition: all .5s ease;
    -o-transition: all .5s ease;
}

header nav{
    position: absolute;
    bottom: 0;
    height: 60px;
    line-height: 60px;
    width: 100%;
    background-color: rgba(0,0,0,.1);
}

header nav li{
    display: inline-block;
    padding: 10px 15px;
    line-height: 1;
    cursor: pointer;
}

header nav li a{
    color: #fff;
    text-decoration: none;
}

header nav li a:hover{
    color: #dfaaff;
    text-decoration: none;
}

section{
    padding: 20px;
    margin-bottom: 40px;
}

.wrapper{
    width: 800px;
    margin: 0 auto;
}

/*

    sticky header

*/


.sticky-header{
    padding-top: 100px;
}

.sticky-header header{
    height: 60px;
    transition: height 0.5s ease;
}

.sticky-header h1{
    transform: scale(0);
}
              
            
!

JS

              
                let wLoad = $("body").load();

let checkScrollPosition = function () {

    let scrollTop = $(window).scrollTop();

    if(scrollTop >= 30  && wLoad){

        wLoad = false;

        $("body").addClass("sticky-header");
        $(".sticky-header header").css({
            'transition': 'none'
        });

    } else if (scrollTop >= 30 && !wLoad) {

        $("body").addClass("sticky-header");
        $(".sticky-header header").css({
            'transition': 'height 0.5s ease'
        });

    } else if (scrollTop <= 30 && wLoad){

        wLoad = false;

    } else{
        $("body").removeClass("sticky-header");
    }

};

$(window).scroll(function(){

    checkScrollPosition();

});



              
            
!
999px

Console