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 id="fixed-top" class="fixed-top">
  <div class="inner">
    <h1>Fixed positioned header with variable height.</h1>
    <p>The header is cloned with JS and then prepended to the body element and put back in the flow. It is set to visibility hidden and sits under the fixed nav thus mimicing its exact size even when the window is resized in a fluid layout.</p>
    <p>There is no need to monitor the resize event or do any more calculations once the page has loaded and so the page can be resized or scroll smoothly unlike when the resize event is monitored or even when throttled. Of course if you dynamically add
      content to the fixed header you would need to re-clone and place the faux header again. It would alse be wise to use media queries to remove fixed positiong for smaller height/width devices to avoid scrolling if the header has a lot of content.</p>
    <nav>
      <ul class="nav">
        <li><a class="inpage-link" href="#section1"><span>Section 1</span></a></li>
        <li><a class="inpage-link" href="#section2"><span>Section 2</span></a></li>
        <li><a class="inpage-link" href="#section3"><span>Section 3</span></a></li>
        <li><a class="inpage-link" href="#section4"><span>Section 4</span></a></li>
        <li><a class="inpage-link" href="#section5"><span >Section 5</span></a></li>
      </ul>
    </nav>
  </div>
</header>
<div class="main">
  <div class="destination" id="section1"></div>
  <section>
    <h2>Scrolling Content - section 1</h2>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
  </section>
  <div class="destination" id="section2" style="margin-top:0"></div>
  <section>
    <h2>Scrolling Content - section 2</h2>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
  </section>
  <div class="destination" id="section3"></div>
  <section>
    <h2>Scrolling Content - section 3</h2>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
  </section>
  <div class="destination" id="section4"></div>
  <section>
    <h2>Scrolling Content - section 4</h2>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
  </section>
  <div class="destination" id="section5"></div>
  <section>
    <h2>Scrolling Content - section 5</h2>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
    <p>Stirred by starlight citizens of distant epochs, prime number made in the interiors of collapsing stars, vastness is bearable only through love? Tesseract. Muse about something incredible is waiting to be known hydrogen atoms Apollonius of Perga light
      years rich in heavy atoms. Muse about, cosmos finite but unbounded rings of Uranus! Not a sunrise but a galaxyrise vanquish the impossible shores of the cosmic ocean how far away quasar, another world, not a sunrise but a galaxyrise vanquish the
      impossible rogue worldlets cosmic ocean, ship of the imagination brain is the seed of intelligence, corpus callosum, the sky calls to us trillion Flatland! Extraplanetary Cambrian explosion vanquish the impossible cosmos star stuff harvesting star
      light extraplanetary hearts of the stars descended from astronomers!</p>
    <p>Hearts of the stars! Consciousness descended from astronomers, are creatures of the cosmos, tendrils of gossamer clouds, Apollonius of Perga birth muse about! Jean-François Champollion explorations realm of the galaxies, rogue hundreds of thousands
      cosmic fugue how far away another world brain is the seed of intelligence Orion's sword. Across the centuries. Shores of the cosmic ocean extraplanetary globular star cluster? Science, Jean-François Champollion Rig Veda not a sunrise but a galaxyrise
      Drake Equation vanquish the impossible, radio telescope vanquish the impossible tingling of the spine realm of the galaxies and billions upon billions upon billions upon billions upon billions upon billions upon billions.</p>
  </section>
</div>
              
            
!

CSS

              
                html {
	box-sizing: border-box;
}
html {
	scroll-behavior: smooth;
}
*, *:before, *:after {
	box-sizing: inherit;
}
html, body {
	margin: 0;
	padding: 0;
}
ul {
	margin: 0;
	padding: 0;
	list-style: none;
}
.fixed-top {
	position: relative;
	z-index: -1;
	color: #fff;
	overflow: auto;
	visibility: hidden;
}
#fixed-top {
	z-index: 999;
	top: 0;
	left: 0;
	right: 0;
	background: rgba(102, 102, 102, 0.9);
	visibility: visible;
	box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}
/* Add fixed positioning only if js is present.*/
.is-fixed .fixed-top {
	max-height: 100%;
	max-height: 100vh;
}
.is-fixed #fixed-top {
	position: fixed;
}
.inner, .main {
	max-width: 980px;
	margin: auto;
	padding: 10px;
}
.nav {
	display: flex;
	text-align: center;
	background: #000;
	position: relative;
}
.nav li {
	flex: 1 0 0;
	display: inline-block;
}
.nav a {
	display: block;
	color: #fff;
	text-decoration: none;
	transition: all 0.5s ease;
	position: relative;
	overflow: hidden;
	background: #000;
}
.nav a:before,.nav a:after {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	transform: translateX(-100%);
	transition: transform 0.5s ease, opacity 0.8s ease;
	z-index: 0;
	background: #f00;
	opacity:0;
}
.nav a:after {transform: translateX(100%);}
.nav li:hover a:before{transform: translateX(-50%);opacity:1;} 
.nav li:hover a:after{transform: translateX(50%);opacity:1;}

.nav a span {
	display: block;
	text-transform: uppercase;
	padding: 10px 5px;
	color: #fff;
	font-weight: bold;
	border: 1px solid #fff;
	position: relative;
	z-index: 1;
}
/* offset links */
/* this works by creating an empty element above the section you want to reach and placing it absolutely but without co-ordinates so it remains effectively in the flow. The js will cycle through these elementsl and apply an offset using a negative margin-top that matches the header height. In this way the content you wanted to reach will then be the header height away from the destination and thus visible underneath the fixed header.*/
/* when an in-page link is clicked (I used a class of inpage-link to make it easier) then the js once again checks the header height and adjusts the top margin of the the destination empty element so that the page junps to the right spot.*/
.destination {
	position:absolute;
	z-index:-1;
	left:-999em;
	height:0;
	width:0;
	overflow:hidden;
}

              
            
!

JS

              
                //vanilla js
(function() {
    var bodyEl = document.getElementsByTagName("BODY")[0];
    var fixedHeader = document.getElementById("fixed-top");
    var clonedElement1 = fixedHeader.cloneNode(true);
    bodyEl.className += " " + "is-fixed";
    clonedElement1.id = "";
    bodyEl.insertBefore(clonedElement1, fixedHeader);

  // all the code below is just to cater for in-page links so that they don't sit under the header. If you are not worried about that then you don't need the following code (apart from the closing brackets of the iffe function)
  
  
    // in page links will hide under the header so need to offset them by height of the header
    var headerHeight = fixedHeader.offsetHeight;
    headerHeight = -headerHeight;
    // first cycle through all target IDS which I have named width a class of .destination and set their margin-top to match the header-height. This should catch people who have arrived by url + fragment identifier */
    [].forEach.call(
        document.querySelectorAll('.destination'),
        function(el) {
            el.classList.add('test');
            el.style.marginTop = headerHeight + "px";
        }
    );
//now catch in page links and account for any change in header height due to page resize etc
    document.addEventListener('click', function(e) {
      // bubble up to find if link was click or child of a link was clicked 
      e = e || event;
        var from = findParent('a', e.target || e.srcElement);
        if (from) {
            /* it's a link, actions here */
            if (from.classList.contains('inpage-link')) {
                headerHeight = fixedHeader.offsetHeight;
                headerHeight = -headerHeight;
                var theDestination = from.getAttribute('href');
                var itemID = theDestination.substring(1, theDestination.length);
                document.getElementById(itemID).style.marginTop = headerHeight + "px";
            }
        }
    });
    //find first parent 
    function findParent(tagname, el) {
        while (el) {
            if ((el.nodeName || el.tagName).toLowerCase() === tagname.toLowerCase()) {
                return el;
            }
            el = el.parentNode;
        }
        return null;
    }
})();

              
            
!
999px

Console