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

              
                <h1>CSS Flexbox Sandbox</h1>

<main class="main-area">
  <div class="centered">
    <section class="menu-section">
      <h2 class="menu-heading">Mixed Menus (drop-down &#43; social)</h2>
      <div class="nav-mixed menu">
        <nav id="multi-level-nav" class="multi-level-nav" role="navigation">
          <ul>
            <li><a href="#">Home</a></li>
            <li class="has-children">
              <a href="#">Food<button class="dropdown-toggle" aria-expanded="false"><span class="screen-reader-text">Expand child menu</span></button></a>
              <ul class="sub-menu">
                <li><a href="#">Chef for Hire</a></li>
                <li><a href="#">Catering</a></li>
                <li><a href="#">Restaurant</a></li>
              </ul>
            </li>
            <li class="has-children">
              <a href="#">Classes<button class="dropdown-toggle" aria-expanded="false"><span class="screen-reader-text">Expand child menu</span></button></a>
              <ul class="sub-menu">
                <li><a href="#">Class Schedule</a></li>
                <li><a href="#">Register</a></li>
                <li><a href="#">Breakfast Class</a></li>
                <li><a href="#">Brunch Class</a></li>
                <li><a href="#">Lunch Class</a></li>
                <li><a href="#">Dinner Class</a></li>
                <li><a href="#">Dessert Class</a></li>
                <li><a href="#">Baking Class</a></li>
                <li><a href="#">Canning Class</a></li>
                <li><a href="#">Shopping Class</a></li>
                <li><a href="#">Tools Class</a></li>
              </ul>
            </li>
            <li><a href="#">About</a>
              <ul class="sub-menu">
                <li><a href="#">The Eat Story</a></li>
                <li><a href="#">Meet the Chef</a></li>
                <li><a href="#">Meet the Team</a></li>
                <li><a href="#">Our Vendors</a></li>
                <li><a href="#">Legal</a></li>
              </ul>
            </li>
            <li><a href="#">Contact</a></li>
          </ul>
        </nav>
        <!-- #multi-level-nav .multi-level-nav -->

        <nav id="social-menu" class="social-menu" role="navigation">
          <ul>
            <li><a href="https://twitter.com/bugsyAlexander"><span class="screen-reader-text">Twitter</span></a></li>
            <li><a href="https://github.com/bugsyAlexander"><span class="screen-reader-text">Github</span></a></li>
            <li><a href="https://www.linkedin.com/pub/mynor-alexander/5b/943/877"><span class="screen-reader-text">LinkedIn</span></a></li>
            <li><a href="http://dribbble.com"><span class="screen-reader-text">Dribbble</span></a></li>
            <li><a href="http://instagram.com"><span class="screen-reader-text">Instagram</span></a></li>
          </ul>
        </nav>
        <!-- .social-menu -->
      </div>
      <!-- .mixed-menu -->
    </section>
    <!-- .menu-section -->
  </div>
  <!-- .centered -->
</main>
              
            
!

CSS

              
                body {
  width: 90%;
  margin: 0 auto;
  color: #666;
}

h1 {color: #e74c3c;}
h1, h2 { text-align: center; }

/* Base styles that apply to all menus */
.menu-section {
	padding-bottom: 2em;
	margin-bottom: 2em;
	border-bottom: 1px solid hsl(0, 0%, );
}

.menu ul {
	list-style-type: none;
	padding: 0;
	margin: 0;
	background: hsl(0, 0%, 15%);
}

.menu li a {
	display: block;
	text-decoration: none;
	color: white;
	padding: .6em 1em;
}

.menu li a:hover {
	background: hsl(0, 0%, 25%);
}

/* Styles for Single Level Menu */
@media screen and (max-width: 30em){
	.multi-level-nav ul ul li a {
		padding-left: 2em;
	}

	.dropdown-toggle {
		display: none;
	}
}

@media screen and (min-width: 30em){
	.multi-level-nav ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
	}	

	.multi-level-nav li {
        flex: 1 0 auto;
		position: relative;
	}

	li.has-children > a {
		padding-right: 0;
	}

	.multi-level-nav ul ul {
		display: none;
		position: absolute;
		z-index:100;
	}

	.multi-level-nav ul ul li {
        flex: 1 1 auto;
	}

	.multi-level-nav ul .toggled-on {
		display: flex;
	}

	.dropdown-toggle {
		margin: 0;
		padding: 0 .5em;
		border: 0;
		font-family: 'FontAwesome';
		content: "";
		text-transform: lowercase; /* Stop screen readers to read the text as capital letters */
		background-color: transparent;
	}

	.dropdown-toggle:after {
		position: relative;
		top: 0;
		left: 0;
		width: 42px;
		color: white;
		content: "\f107";
		line-height: 1em;	
	}

	.dropdown-toggle:hover,
	.dropdown-toggle:focus {
		background: hsl(0, 0%, 25%);
	}

	.dropdown-toggle.toggle-on:after {
		content: "\f106";
	}
}

/* Styles for social media menu */

/* Find src URL and add in correct social media icon. */
.social-menu li a:before {
    font-family: 'Fontawesome';
    -webkit-font-smoothing: antialiased;
    content: '\f08e';
}

.social-menu li a[href*="dribbble.com"]::before { content: '\f17d'; }

.social-menu li a[href*="facebook.com"]::before { content: '\f09a'; }

.social-menu li a[href*="flickr.com"]::before { content: '\f16e'; }

.social-menu li a[href*="foursquare.com"]::before { content: '\f180'; }

.social-menu li a[href*="github.com"]::before { content: '\f09b'; }

.social-menu li a[href*="plus.google.com"]::before { content: '\f0d5'; }

.social-menu li a[href*="instagram.com"]::before { content: '\f16d'; }

.social-menu li a[href*="jsfiddle.com"]::before { content: '\f1cc'; }

.social-menu li a[href*="linkedin.com"]::before { content: '\f0e1'; }

.social-menu li a[href*="pinterest.com"]::before { content: '\f0d2'; }

.social-menu li a[href*="reddit.com"]::before { content: '\f1a1'; }

.social-menu li a[href*="soundcloud.com"]::before { content: '\f1be'; }

.social-menu li a[href*="stackoverflow.com"]::before { content: '\f16c'; }

.social-menu li a[href*="tumblr.com"]::before { content: '\f173'; }

.social-menu li a[href*="twitter.com"]::before { content: '\f099'; }

.social-menu li a[href*="vimeo.com"]::before { content: '\f194'; }

.social-menu li a[href*="vine.co"]::before { content: '\f1ca'; }

.social-menu li a[href*="yelp.com"]::before { content: '\f1e9'; }

.social-menu li a[href*="youtube.com"]::before { content: '\f167'; }

.social-menu li a[href*="wordpress.com"]::before { content: '\f19a'; }

/* Flexbox stuff */

.social-menu ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/*--------------------------------------------------------------
Accessibility
--------------------------------------------------------------*/
/* Text meant only for screen readers */
.screen-reader-text {
	clip: rect(1px, 1px, 1px, 1px);
	position: absolute !important;
	height: 1px;
	width: 1px;
	overflow: hidden;
}

.screen-reader-text:hover,
.screen-reader-text:active,
.screen-reader-text:focus {
	background-color: #f1f1f1;
	border-radius: 3px;
	box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
	clip: auto !important;
	color: #21759b;
	display: block;
	font-size: 14px;
	font-weight: bold;
	height: auto;
	left: 5px;
	line-height: normal;
	padding: 15px 23px 14px;
	text-decoration: none;
	top: 5px;
	width: auto;
	z-index: 100000; /* Above WP toolbar */
}

/* Styles for mixed menu (drop-down + social) */
.nav-mixed {
  background: hsl(0, 0%, 15%);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
              
            
!

JS

              
                (function($) {
	// Drastically modified from the function in the WordPress Twenty Fifteen theme
	// Original source: https://github.com/WordPress/WordPress/blob/master/wp-content/themes/twentyfifteen/js/functions.js
	$('.dropdown-toggle').click(function(e) {
		var _this = $(this);
		e.preventDefault();
		_this.toggleClass('toggle-on');
		_this.parent().next('.sub-menu').toggleClass('toggled-on');
		_this.attr('aria-expanded', _this.attr('aria-expanded') === 'false' ? 'true' : 'false');
		_this.html(_this.html() === '<span class="screen-reader-text">Expand child menu</span>' ? '<span class="screen-reader-text">Collapse child menu</span>' : '<span class="screen-reader-text">Expand child menu</span>');
	});
})(jQuery);
              
            
!
999px

Console