cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


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.

              <nav id="navigation" role="navigation" class="navigation">
  <a href="http://www.alsacreations.com/">Picon bière</a>
  <a href="https://www.goetter.fr">Melfor</a>
  <a href="http://www.alsacreations.com/">Carola</a>
  <a href="https://www.goetter.fr">Wurscht</a>
  <a href="http://www.alsacreations.com/">Choucroute</a>
  <a href="https://www.goetter.fr">Knacks</a>

<div class="main" role="main">
  <button class="nav-button" role="button" type="button" aria-label="navigation"></button>
  <h1>Navigation "push top JS"</h1>
  <p>Navigation mobile-first "Push Top" librement inspiré du code du livre <a href="">Responsive Design Patterns</a> de Ethan Marcotte</p>
    <li>JavaScript pour le comportement "touch" et la génération du bouton de menu</li>
    <li>CSS pour les styles et les transitions</li>
  <p>Le principe général est celui-ci :</p>
    <li>Si JavaScript n'est pas activé ou si le navigateur est ancien, la navigation s'affiche simplement dans le flux, de façon accessible</li>
    <li>Sur petit écran (maxi 544px), "main" s'affiche par dessus "navigation" et le bouton de navigation "nav-button" apparaît. <br>JavaScript s'occupe de l'action "touch" en ajoutant/retirant la classe ".is-opened" sur "main".</li>
    <li>Sur grand écran (mini 545px), "navigation" est simplement placée dans le flux en haut de "main".</li>
  <p>Lorem Elsass ipsum réchime amet non Choucroute knack tchao bissame hopla. Wotch a kofee avec ton BibalaekaesSalat et ta wurscht ?</p>
  <p>Yeuh non che suis au réchime, je ne mange plus que des Grumbeere light et che fais de la chym avec Chulien. Tiens, un Picon sur le comptoir.</p>
  <p>Allez tchao bissame !</p>
              /* Global deco */

* {
  box-sizing: border-box;

html {
  font-size: 62.5%;
  font-size: calc(1em * .625);

body {
  margin: 0;
  font-size: 1.6em;
  font-family: arial, sans-serif;

.main {
  padding: 5rem 2rem;
  background: #fff;

/* Global layout */

.navigation {
  background: #333;
.navigation > a {
  display: block;
  padding: 10px;
  background: rgba(255,255,255,.3);
  margin-bottom: 2px;
  color: #fff;
  text-decoration: none;
.navigation > a:hover,
.navigation > a:focus,
.navigation > a:active {
  background: #555;

.nav-button {
  display: none; /* no button by default */
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 1; /* will be above everything */
  height: 2.4rem;
  width: 2.8rem;
  background-color: transparent;
  background-image: linear-gradient(to right, currentColor, currentColor);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 5px;
  padding: 0;
  outline: 0;
  border: 0;
  color: #333;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
.nav-button::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  display: block;
  height: 5px;
  background: currentColor;
  transition: .25s;
  transition-property: transform, top;
  will-change: transform, top;
.nav-button::before {
  top: 0;
.nav-button::after {
  top: calc(100% - 4px);

@media (max-width: 545px) {
  .js-enabled .nav-button {
    display: inline-block;
  .js-enabled .navigation {
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 0; /* will be under everything */

  /* styling opened nav */
  .js-enabled .main {
    position: relative;
    transition: transform .25s;
    will-change: transform;
  .js-enabled .main.is-opened {
    transform: translateY(60vw);

              (function() {

// old browser or not ?
if ( !('querySelector' in document && 'addEventListener' in window) ) {
window.document.documentElement.className += ' js-enabled';

function toggleNav() {

// Define targets
var target = document.querySelector('.main');
var button = document.querySelector('.nav-button');

// click-touch event
if ( button ) {
  function (e) { 
  }, false );
} // end toggleNav()


Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................