Pen Settings



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


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


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.


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.


                <header class="header" role="banner">
  <h1 class="title">
    <img src="" width="60" /> 
    <span>Mon site web</span>
  <button class="burger-button" type="button" role="button" aria-label="open/close navigation"><i></i></button>

<nav role="navigation" class="navigation" tabindex="0">
  <a class="navigation__link" href="">Picon bière</a>
  <a class="navigation__link" href="">Melfor</a>
  <a class="navigation__link" href="">Carola</a>
  <a class="navigation__link" href="">Wurscht</a>
  <a class="navigation__link" href="">Choucroute</a>
  <a class="navigation__link" href="">Knacks</a>

<main class="main" role="main">
  <h1>Navigation "push top JS"</h1>
  <p>Navigation "Push Top" : au clic/tap sur le bouton burger, la partie principale se décale vers le bas, laissant découvrir la navigation.</p>
    <li>JavaScript pour le comportement "touch"</li>
    <li>CSS pour les styles et les transitions</li>
  <p>Le principe général est celui-ci :</p>
    <li>"main" s'affiche par dessus "navigation". Ce dernier étant en position absolute et z-index inférieur.</li> 
    <li>JavaScript s'occupe de l'action "touch" en ajoutant/retirant la classe ".is-opened" sur "main".</li>
  <p>Accessibilité :</p>
    <li>La navigation au clavier est possible (la méthode focus() donne le focus à la navigation après avoir actionné le bouton burger)</li>
    <li>Le bouton burger est entouré (outline) lors de la navigation clavier uniquement (pas au clic), grâce à :focus-visible</li>
  <p>Grid Layout est ici employé pour :</p>
    <li>Le bouton burger (grille de 3 rangées, avec pseudo-éléments ::before et ::after)</li>
    <li>La navigation (espacements internes grâce à gap)</li>


                /* Config */
:root {
  --burger-button-size: 1.6rem;
  --burger-button-thickness: 6px;
  --burger-button-color: purple;
  --nav-bg: transparent;
  --nav-link-bg: bisque;
  --nav-link-color: #000;
  --nav-link-hover: peru;
  --main-bg: beige;

/* Global layout */

html, body {
  overflow-x: hidden; /* you shall not pass! */

/* styling  header */
.header {
  display: grid;
  padding: 2rem;
  grid-template-columns: auto auto;
  justify-content: space-between;

/* styling  nav */
.navigation {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  max-height: 0;
  overflow: hidden;

/* styling opened nav */
.navigation {
  transition: max-height .25s;
  will-change: max-height;
} {
  max-height: 20rem;
  overflow: visible;

/* styling main */
.main {
  position: relative;

/* styling button */
.burger-button {
  appearance: none;
  all: unset;
  display: inline-grid;
  grid-template-rows: repeat(3, var(--burger-button-thickness));
  align-content: space-between;
  vertical-align: top;
  height: var(--burger-button-size);
  width: var(--burger-button-size);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
.burger-button::before {
  content: "";
  background: var(--burger-button-color);
.burger-button:focus-visible {
  /* affichage du focus lors de la navigation au clavier */
  outline: 2px dashed var(--burger-button-color);
  outline-offset: 5px;

/* Global deco */

* {
  box-sizing: border-box;

body {
  margin: 0;
  font-family: system-ui, sans-serif;

.title {
  display: grid;
  grid-template-columns: auto auto;
  margin: 0;
  gap: 1rem;
  align-items: center;
  color: #555;
  font-weight: 200;

.main {
  border-top: 6px solid #000;
  padding: 2rem;
  background: var(--main-bg);

.navigation {
  background: var(--nav-bg);
.navigation__link {
  padding: 1rem;
  background: var(--nav-link-bg);
  color: var(--nav-link-color);
  text-decoration: none;
.navigation__link:active {
  background: var(--nav-link-hover);


                (function() {
function toggleNav() {
// Define targets
var target = document.querySelector('.main');
var button = document.querySelector('.burger-button');
var navigation = document.querySelector('.navigation');

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