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 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

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

              
                

<nav>
  <button class="menubutton" onclick="this.classList.toggle('showmenu')">Menü</button> 
  
  <ul>
    <li class="current"><a href="#">Startseite</a></li>
    <li><a href="#">News</a></li>
    <li><a href="#">Über&nbsp;uns</a></li>
    <li><a href="#">Kontakt</a></li>
  </ul>
</nav>

<hr>

<p>Zum Testen können Sie das JavaScript für die mobile Navigation per Klick aus- und einschalten und die Fensterbreite verändern. </p>
<button class="jstoggle off" onclick="document.documentElement.classList.remove('js'); document.documentElement.classList.add('no-js')">Mobile Navigation ohne JavaScript</button> &nbsp; &nbsp;
<button class="jstoggle on" onclick="document.documentElement.classList.remove('no-js'); document.documentElement.classList.add('js')">Mobile Navigation mit JavaScript</button> 

  <h2>Über diese Navigation</h2> 

<p>Diese Navigation ist responsiv und folgt dem Prinzip des <em>progressive enhancement</em>: </p>

  <ol> 
    <li>Ohne JavaScript   
      <ul> 
        <li>wird die Navigationsliste offen angezeigt
und der Menübutton versteckt. </li> 
        <li>können Besucher können auch ohne
JavaScript navigieren. </li> 
      </ul> 
    </li> 
    <li>Mit JavaScript  
      <ul> 
        <li>ist der
Menübutton sichtbar und die Navigationsliste ausgeblendet. </li> 
        <li> wird die
Navigationsliste durch Antippen des Menübuttons sanft eingeblendet.</li> 
      </ul>
    </li> 
  </ol>
  <p>Weitere Infos <a href="https://html-und-css.de/responsive-navigation-progressive-enhancement/" target="_blank" rel="noopen noreferrer">siehe Beitrag auf der Website zum Buch</a>. 




              
            
!

CSS

              
                body {
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.5; 
}

/* Styling for the navigation */ 

/* basic styling - mobile first */
nav { margin-top: 2rem; }
nav ul { 
  display: flex; 
  flex-flow: column; 
  list-style: none; 
  padding: 0; 
  margin: 0; 
}

nav a {
  display: block; 
  text-decoration: none; 
  background: #333; color: white; 
  padding: 0.5rem 1rem;
  /* pull right margin over the padding, for .current, :hover and :focus */
  margin-right: -1rem;   
}

nav .current a, 
nav a:hover, 
nav a:focus { 
  background: #0b74b8; 
  color: white;   
}

.no-js .menubutton { 
  display: none; 
}

/* style the menubutton */
.js .menubutton { 
  display: flex; 
  align-items: center; 
  cursor: pointer; 
  
  background: #333; 
  color: white; 
  font: inherit; 
  
  padding: 0.5rem 1rem; 
  border: 0; 
  margin: 0; 
}

/* Three lines = https://unicode-table.com/en/2630/ (instead of SVG icon) */ 
.js .menubutton::before {
  content: "\2630\00A0"; 
  /* manually adjust vertical alignment, not necessary with SVG icon */
  margin-bottom: 3px; 
}

/* hide navigqtion list on mobile */
.js nav ul {
  /* max-height can be animated with transition, see below */
  max-height: 0; 
  overflow: hidden; 
  padding: 0; 
} 

/* show navigation list after click/tap on menubutton */
.js .menubutton.showmenu + ul {
  /* value should be big enough to contain the menu in all circumstances */ 
  max-height: 100rem; 
  transition: max-height 500ms; 
}
/* X icon = https://unicode-table.com/en/2716/ */ 
.js .menubutton.showmenu::before {
  content: "\2716\00A0"; 
  margin-bottom: 0;
}

/* style horizontal navigation   */

@media screen and (min-width: 600px) {

  /* Hide menubutton */ 
  .menubutton {
    display: none !important; 
  } 
  
  nav { 
    max-width: none; 
  }
  
  /* list items horizontal */ 
  nav ul { 
    max-height: none !important; 
    flex-flow: row; 
    padding: 0; 
  }

  nav li {
    flex: 1; 
    max-width: 10rem; 
    text-align: center; 
    border-left: 1px solid #eee; 
    margin: 0; 
  }
  nav li:first-child {
    margin: 0; 
  }
  nav li:last-child {
    border-right: 1px solid #eee; 
    margin: 0; 
  }
  nav a {
    margin-right: 0; 
  }

} /* Ende @media */ 


/* Styling for the rest of the Pen */ 

hr {
  margin: 3rem ; 
}

.jstoggle {
  cursor: pointer; 
  font: inherit; 
  background-color: gainsboro; 
  color: #333; 
  padding: 0.5rem 1rem; 
  border: 0; 
  margin: 0 0 1rem 0; 
}

.js .jstoggle.on, 
.no-js .jstoggle.off,
.jstoggle:hover, 
.jstoggle:focus {
  background: darkred; 
  color: white; 
}

.js .jstoggle.on::after { content: ": AN"; font-weight: bold; }
.js .jstoggle.off::after { content: ""; }
.no-js .jstoggle.on::after { content: ""; }
.no-js .jstoggle.off::after { content: ": AN"; font-weight: bold; }

ol ul li::marker {
  content: "... "; 
}


              
            
!

JS

              
                
              
            
!
999px

Console