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

              
                <figure class="d-container">

  <nav class="d-flexbox-navigation">

    <ul class="js-navigation-items">
      <li>
        <a href="#">Nav Item 1</a>
      </li>


    </ul>

  </nav>

  <nav class="d-navigation">

    <ul>
      <li>
        <a class="d-btn-primary js-btn-add" href="#">
          Add Item
        </a>
      </li>
      <li>
        <a class="d-btn-primary js-btn-remove" href="#">
          Remove Item
        </a>
      </li>
    </ul>

  </nav>
</figure>
              
            
!

CSS

              
                .d-flexbox-navigation {
  background: #484281;
  border: 1px solid #111;
  padding: 1em;
}

.d-flexbox-navigation ul {
  padding: 0;
  margin: 0;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 20%;
  -ms-flex: 1 1 20%;
  flex: 1 1 20%;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -webkit-flex-direction: row;
  -ms-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-transition: all 0.4s ease-in-out;
  transition: all 0.4s ease-in-out;
}

.d-flexbox-navigation li {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 20%;
  -ms-flex: 1 1 20%;
  flex: 1 1 20%;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: start;
  -webkit-justify-content: flex-start;
  -ms-flex-pack: start;
  justify-content: flex-start;
  -webkit-transition: all 0.4s ease-in-out;
  transition: all 0.4s ease-in-out;
}

.d-flexbox-navigation li a {
  border: 1px solid #111;
  padding: 1.5em;
  display: block;
  background: #fff;
  border-radius: 3px;
  text-decoration: none;
  text-align: center;
  color: #333;
  width: 100%;
  -webkit-transition: all 0.4s ease-in-out;
  transition: all 0.4s ease-in-out;
}
.d-flexbox-navigation li a:hover {
  background: #a303cb;
  color: #fff;
}

.d-flex {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  margin: 0 auto;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-box-align: stretch;
  -webkit-align-items: stretch;
  -ms-flex-align: stretch;
  align-items: stretch;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}
@media all and (min-width: 49em) {
  .d-flex {
    -webkit-flex-wrap: nowrap;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;
  }
}

.d-flex li {
  color: #fff;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  list-style: none;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  padding: 1em;
}

.d-flex li:nth-of-type(1) {
  background: #484281;
}

.d-flex li:nth-of-type(2) {
  background: #5248af;
}

.d-flex li:nth-of-type(3) {
  background: #786bfa;
}

.d-flex li:nth-of-type(4) {
  background: #aba3f9;
}

.d-flex li:nth-of-type(5) {
  background: #a303cb;
}

.d-ex1 {
  max-width: 600px;
}

.d-ex2 {
  max-width: 600px;
}

.d-ex3 {
  max-width: 1000px;
}

.d-ex4 {
  max-width: 1000px;
}
@media all and (max-width: 48em) {
  .d-ex4 {
    max-width: 320px;
    -webkit-box-align: center;
  }
}

.d-ex5 {
  max-width: 600px;
}

.d-ex6 {
  max-width: 600px;
}

.d-ex1 li:nth-of-type(1) {
  -webkit-box-flex: 2;
  -webkit-flex: 2 0 100px;
  -ms-flex: 2 0 100px;
  flex: 2 0 100px;
}

.d-ex1 li:nth-of-type(2) {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 150px;
  -ms-flex: 0 0 150px;
  flex: 0 0 150px;
}

.d-ex1 li:nth-of-type(3) {
  -webkit-box-flex: 2;
  -webkit-flex: 2 0 100px;
  -ms-flex: 2 0 100px;
  flex: 2 0 100px;
}

.d-ex2 li:nth-of-type(1) {
  -webkit-box-flex: 2;
  -webkit-flex: 2 0 150px;
  -ms-flex: 2 0 150px;
  flex: 2 0 150px;
}

.d-ex2 li:nth-of-type(2) {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 150px;
  -ms-flex: 0 0 150px;
  flex: 0 0 150px;
}

.d-ex2 li:nth-of-type(3) {
  -webkit-box-flex: 2;
  -webkit-flex: 2 0 100px;
  -ms-flex: 2 0 100px;
  flex: 2 0 100px;
}

.d-ex3 li:nth-of-type(1) {
  -webkit-box-flex: 3;
  -webkit-flex: 3 0 0;
  -ms-flex: 3 0 0;
  flex: 3 0 0;
}

.d-ex3 li:nth-of-type(2) {
  -webkit-box-flex: 1;
  -webkit-flex: 1 0 0;
  -ms-flex: 1 0 0;
  flex: 1 0 0;
}

.d-ex3 li:nth-of-type(3) {
  -webkit-box-flex: 2;
  -webkit-flex: 2 0 0;
  -ms-flex: 2 0 0;
  flex: 2 0 0;
}

.d-ex4 li:nth-of-type(1) {
  -webkit-box-flex: 1;
  -webkit-flex: 1 0 150px;
  -ms-flex: 1 0 150px;
  flex: 1 0 150px;
}

.d-ex4 li:nth-of-type(2) {
  -webkit-box-flex: 3;
  -webkit-flex: 3 0 200px;
  -ms-flex: 3 0 200px;
  flex: 3 0 200px;
}

.d-ex4 li:nth-of-type(3) {
  -webkit-box-flex: 2;
  -webkit-flex: 2 0 175px;
  -ms-flex: 2 0 175px;
  flex: 2 0 175px;
}

.d-ex4 li:nth-of-type(4) {
  -webkit-box-flex: 4;
  -webkit-flex: 4 0 225px;
  -ms-flex: 4 0 225px;
  flex: 4 0 225px;
}

.d-ex5 li:nth-of-type(1) {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 200px;
  -ms-flex: 1 1 200px;
  flex: 1 1 200px;
}

.d-ex5 li:nth-of-type(2) {
  -webkit-box-flex: 3;
  -webkit-flex: 3 2 200px;
  -ms-flex: 3 2 200px;
  flex: 3 2 200px;
}

.d-ex5 li:nth-of-type(3) {
  -webkit-box-flex: 2;
  -webkit-flex: 2 3 200px;
  -ms-flex: 2 3 200px;
  flex: 2 3 200px;
}

.d-ex5 li:nth-of-type(4) {
  -webkit-box-flex: 4;
  -webkit-flex: 4 1 200px;
  -ms-flex: 4 1 200px;
  flex: 4 1 200px;
}

.d-ex6 li:nth-of-type(1) {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 150px;
  -ms-flex: 1 1 150px;
  flex: 1 1 150px;
}

.d-ex6 li:nth-of-type(2) {
  -webkit-box-flex: 3;
  -webkit-flex: 3 2 400px;
  -ms-flex: 3 2 400px;
  flex: 3 2 400px;
}

.d-ex6 li:nth-of-type(3) {
  -webkit-box-flex: 2;
  -webkit-flex: 2 3 400px;
  -ms-flex: 2 3 400px;
  flex: 2 3 400px;
}

.d-ex6 li:nth-of-type(4) {
  -webkit-box-flex: 4;
  -webkit-flex: 4 0 200px;
  -ms-flex: 4 0 200px;
  flex: 4 0 200px;
}

.d-flex-order {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  max-width: 100%;
  margin: 0 auto;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-pack: start;
  -webkit-justify-content: flex-start;
  -ms-flex-pack: start;
  justify-content: flex-start;
  /*makes it to the left */
  -webkit-box-align: stretch;
  -webkit-align-items: stretch;
  -ms-flex-align: stretch;
  align-items: stretch;
  /* needed to make all items equal height */
}

.d-flex-order > li {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 100%;
  -ms-flex: 0 0 100%;
  flex: 0 0 100%;
  list-style: none;
}
@media all and (min-width: 48em) {
  .d-flex-order > li {
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 33%;
    -ms-flex: 0 0 33%;
    flex: 0 0 33%;
  }
}

.d-flex-order > li a {
  color: #333;
  background: #fff;
  border: 1px solid #ddd;
  display: block;
  width: 100%;
  margin: 1em;
  padding: 1.5em;
  text-decoration: none;
  -webkit-transition: background 0.35s ease;
  transition: background 0.35s ease;
}
.d-flex-order > li a:hover {
  background: #eee;
}

.d-flex-order > li h2 {
  display: block;
  font-size: 2.2em;
  line-height: 1.3;
}

.d-flex-order > li time {
  color: #666;
  display: block;
  margin: 0.5em 0 1em 0;
}

.d-flex-order > li p {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}

.d-flex-order > li.d-flex-pinned {
  -webkit-box-ordinal-group: 0;
  -webkit-order: -1;
  -ms-flex-order: -1;
  order: -1;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 100%;
  -ms-flex: 0 0 100%;
  flex: 0 0 100%;
}
@media all and (min-width: 48em) {
  .d-flex-order > li.d-flex-pinned {
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 66%;
    -ms-flex: 0 0 66%;
    flex: 0 0 66%;
  }
}

.d-flex-stretch {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  max-width: 960px;
  margin: 0 auto;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-pack: start;
  -webkit-justify-content: flex-start;
  -ms-flex-pack: start;
  justify-content: flex-start;
  /*makes it to the left */
  -webkit-box-align: stretch;
  -webkit-align-items: stretch;
  -ms-flex-align: stretch;
  align-items: stretch;
  /* needed to make all items equal height */
}

.d-flex-stretch > div {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-flex: 1;
  -webkit-flex: 1 0 30%;
  -ms-flex: 1 0 30%;
  flex: 1 0 30%;
  border: 1px solid #ddd;
  border-left: none;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  padding: 2em;
  background: #fff;
}

.d-flex-stretch > div:first-child {
  border-left: 1px solid #ddd;
}

.d-flex-stretch h2 {
  margin: 0 0 1em 0;
}

.d-flex-vertical {
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  justify-content: center;
  min-height: 30em;
}

.d-flex-vertical-center {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  background: #fff;
  color: #333;
  padding: 2.5em;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 200px;
  -ms-flex: 0 0 200px;
  flex: 0 0 200px;
  border: 1px solid #ddd;
}
@media all and (min-width: 30em) {
  .d-flex-vertical-center {
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 400px;
    -ms-flex: 0 0 400px;
    flex: 0 0 400px;
  }
}

.is-removing {
  -webkit-animation: flexRemove 0.5s 0.5s ease forwards 1;
  animation: flexRemove 0.5s 0.5s ease forwards 1;
}

.is-adding {
  -webkit-animation: flexInsert 0.5s 0.5s ease forwards 1;
  animation: flexInsert 0.5s 0.5s ease forwards 1;
}

@-webkit-keyframes flexInsert {
  0% {
    -webkit-transform: scale(0);
    transform: scale(0);
  }

  70% {
    -webkit-transform: scale(1.05);
    transform: scale(1.05);
  }

  80% {
    -webkit-transform: scale(0.95);
    transform: scale(0.95);
  }

  100% {
    -webkit-transform: scale(1);
    transform: scale(1);
  }
}

@keyframes flexInsert {
  0% {
    -webkit-transform: scale(0);
    transform: scale(0);
  }

  70% {
    -webkit-transform: scale(1.05);
    transform: scale(1.05);
  }

  80% {
    -webkit-transform: scale(0.95);
    transform: scale(0.95);
  }

  100% {
    -webkit-transform: scale(1);
    transform: scale(1);
  }
}
@-webkit-keyframes flexRemove {
  0% {
    -webkit-transform: scale(1);
    transform: scale(1);
  }

  100% {
    -webkit-transform: scale(0);
    transform: scale(0);
  }
}
@keyframes flexRemove {
  0% {
    -webkit-transform: scale(1);
    transform: scale(1);
  }

  100% {
    -webkit-transform: scale(0);
    transform: scale(0);
  }
}

.d-btn-primary:hover {
background: #333;
}
.d-navigation li a {
text-decoration: none;
display: block;
padding: 1.25em 2em;
margin: 1em;
border-radius: 40px;
}
.d-btn-primary {
background: #35b5ac;
border: 1px solid #247b75;
color: #fff;
-webkit-transition: background .4s ease-in-out;
transition: background .4s ease-in-out;
}

.d-navigation {
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
margin: 2em auto 0;
}

.d-navigation li {
list-style: none;
float: left;
}

              
            
!

JS

              
                var d,
	btnAdd,
	btnRemove,
	flexNav,
	newListItem,
	newAnchor,
	createNavigationItem,
	navItemsNumber,
	shrinkFlexItem,
	growFlexItem,
	demoEventType;

d = document;
navItemsNumber = 2;
demoEventType = "click";

//createdInsert = d.createDocumentFragment();
btnAdd = d.querySelector('.js-btn-add');
btnRemove = d.querySelector('.js-btn-remove');
flexNav = d.querySelector('.js-navigation-items');


createNavigationItem = function(){

	newListItem = d.createElement('li');
	newAnchor = d.createElement('a');
	newAnchor.setAttribute('href', '#');
	newAnchor.innerHTML = "Nav Item " + (navItemsNumber + 1);
	newListItem.appendChild(newAnchor);

}

shrinkFlexItem = function(){


}

growFlexItem = function(){


}

addItem = function(e){

	e.preventDefault();
	createNavigationItem();
	navItemsNumber++;
	flexNav.appendChild(newListItem);

}
removeItem = function(e){
	e.preventDefault();
	if(navItemsNumber > 1) {
		
		navItemsNumber--;
		flexNav.removeChild(flexNav.lastElementChild);

	}
	

}

btnAdd.addEventListener(demoEventType, addItem);
btnRemove.addEventListener(demoEventType, removeItem);

              
            
!
999px

Console