123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <header class="header-base">
  <h1 class="header__title">JS &amp; CSS for the Win</h1>

  <label class="input-label" for="choose">
    Choose an Option
  </label>

  <div class="select-area">
    <select name="choose" id="choose" class="input-select">
      <option value="nul" selected disabled>Make a Selection</option>
      <option value="opt1">Option 1</option>
      <option value="opt2">Option 2</option>
      <option value="opt3">Option 3</option>
    </select>
  </div>
</header>

<main role="main" class="main-content">

  <section class="options opt1">
    <div class="content">
      <h1>Option 1</h1>
      <p>
        You chose Option 1. That's super great.
      </p>
      <p>
        I hope this works out well for you.
      </p>
      <p>
        Strip steak short ribs swine ham hock, pork belly t-bone pork turducken filet mignon pancetta brisket jerky beef ribs tenderloin porchetta. Short ribs venison brisket doner, swine pancetta kielbasa turkey pig boudin spare ribs ham frankfurter. Rump kevin flank filet mignon short ribs tail pastrami meatloaf.
      </p>
      <p>
        Venison corned beef ham ribeye. Flank pig filet mignon tri-tip tenderloin ham tail salami spare ribs meatball tongue. Kielbasa strip steak pork belly jerky chuck tail capicola filet mignon meatloaf salami frankfurter boudin tongue ball tip corned beef.
      </p>
    </div>
  </section>

  <section class="options opt2">
    <div class="content">
      <h1>Option 2</h1>
      <p>
        You chose Option 2.
      </p>
      <p>
        Second best is alright I suppose.
      </p>
      <p>
        Strip steak short ribs swine ham hock, pork belly t-bone pork turducken filet mignon pancetta brisket jerky beef ribs tenderloin porchetta. Short ribs venison brisket doner, swine pancetta kielbasa turkey pig boudin spare ribs ham frankfurter. Rump kevin flank filet mignon short ribs tail pastrami meatloaf.
      </p>
      <p>
        Venison corned beef ham ribeye. Flank pig filet mignon tri-tip tenderloin ham tail salami spare ribs meatball tongue. Kielbasa strip steak pork belly jerky chuck tail capicola filet mignon meatloaf salami frankfurter boudin tongue ball tip corned beef.
      </p>
    </div>
  </section>

  <section class="options opt3">
    <div class="content">
      <h1>Option 3</h1>
      <p>
        You chose Option 3.
      </p>
      <p>
        This is probably the least desirable option.
        It's number 3 for a reason y'all.
      </p>
      <p>
        Strip steak short ribs swine ham hock, pork belly t-bone pork turducken filet mignon pancetta brisket jerky beef ribs tenderloin porchetta. Short ribs venison brisket doner, swine pancetta kielbasa turkey pig boudin spare ribs ham frankfurter. Rump kevin flank filet mignon short ribs tail pastrami meatloaf.
      </p>
      <p>
        Venison corned beef ham ribeye. Flank pig filet mignon tri-tip tenderloin ham tail salami spare ribs meatball tongue. Kielbasa strip steak pork belly jerky chuck tail capicola filet mignon meatloaf salami frankfurter boudin tongue ball tip corned beef.
      </p>
    </div>
  </section>

</main>
            
          
!
            
              *, *:before, *:after {
  box-sizing: border-box;
  font-family: arial;
}

html, body, main, .jqueryOptions {
  height: 100%;
}

body {
  background: #eaeaea;
  font-size: 20px;
  margin: 0;
  padding: 0;
}

h1, h2, h3, p {
  margin-top: 0;
}

.content {
  margin: auto;
  max-width: 80%;
  padding: 20px;
}

.content :last-child {
  margin-bottom: 0;
}

.header-base {
  background: #eee;
  border-bottom: 1px solid #ddd;
  height: 100%;
  left: 0;
  padding: 20px;
  position: fixed;
  top: 0;
  width: 320px;
  z-index: 3;

}

.header__title {
  font-size: 1.3em;
}

.main-content {
  padding-left: 320px;
}

.footer-base {
  background: #dadada;
  bottom: 0;
  font-size: .55em;
  left: 0;
  position: fixed;
  text-align: center;
  width: 100%;
}


.select-area:after {
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid #444;
  bottom: 0;
  content: '';
  height: 0;
  margin: auto;
  pointer-events: none;
  position: absolute;
  right: 8px;
  top: 0;
}

.select-area {
  background-color: #fff;
  border: 1px solid #ccc;
  margin-bottom: 16px;
  padding: 8px 4px;
  position: relative;
}

.input-label {
  cursor: pointer;
  display: inline-block;
  margin-bottom: 8px;
}

.input-select {
  -webkit-appearance: textarea;
  -moz-appearance: window;
  background: none;
  border: 0;
  font-size: .8em;
  font-weight: 300;
  line-height: 1.33333;
  margin: 0;
  overflow: hidden;
  padding-right: 28px;
  padding: 0;
  text-overflow: ellipsis;
  width: 100%;
  width: 110% \9;
  z-index: 2;
}

.options {
  height: 0% ;
  overflow: auto;
  transition: all .3s;
  visibility: hidden;
}

.jqueryOptions:before,
.options:before {
  content: '';
  display: block;
  height: 100%;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateY(100%);
  width: 100%;
  z-index: -1;
}

.current-opt:before,
.options:before {
  transform: translateY(0%);
}

.opt1 {
  background: #d6f2e0;
}

.opt1:before {
  background: #d6f2e0;
}

.opt2 {
  background: #d6eff2;
}

.opt2:before {
  background: #d6eff2;
}

.opt3 {
  background: #f2e6d6;
}

.opt3:before {
  background: #f2e6d6;
}

.show {
  display: block;
  height: 100%;
  /*overflow: visible;*/
  position: relative;
  visibility: visible;
}

@media screen and (max-width: 768px) {
  body {
    font-size: 16px;
  }

  .content {
    max-width: 100%;
  }
}
            
          
!
            
              (function() { //IIFE

  'use strict';

  // selectInput is the select element w/ id of 'choose'
  var selectInput = document.getElementById('choose'),
      // here we are compiling a list of all the nodes w/ a class of 'options'
      panels = document.querySelectorAll('.options'),
      currentSelect,
      elmClass,
      i;


  // To allow for compatibility with IE < 10,
  // we'll use these custom add/remove class functions
  // instead of classList.add()/.remove()

  function addClass( elm, newClass ) {
    elm.className += ' ' + newClass;
  }


  function removeClass( elm, deleteClass ) {
    elm.className = elm.className.replace(new RegExp("\\b" + deleteClass + "\\b", 'g'), '').trim();
    // the RegExp here makes sure that only the class we want to delete, and not any other
    // potentially matching stings get deleted.
    // e.g. -- if deleteClass = options and we also had a class of options--1 and options
    // on the elm, just the class of options would get deleted
  }


  // Function to go through all nodes with 'options' as a class
  // and remove the class of 'show' from them.
  function clearShow() {
    for ( i = 0; i < panels.length; i++ ) {
      removeClass( panels[i], 'show');
    }
  }


  // Function to add the class of show to the node that has
  // the class that matches the current value of the select drop down (#choose)
  function addShow( showThis ) {
    var el = document.getElementsByClassName( showThis );
    for ( i = 0; i < el.length; i++ ) {
      addClass( el[i], 'show')
    }
  }


  // Run the clear/add functions and set the value for what
  function vUpdate () {
    currentSelect = selectInput.value;

    clearShow();
    addShow(currentSelect);
  }


  // Update the value of currentSelect when selectInput changes option focus
  selectInput.addEventListener('change', vUpdate);


  // If a page is refreshed the select input may not reset to the default
  // option. If that's the case, find the current value of #choose
  // and run addShow() to make that content block visible
  if (selectInput.value !== 'nul') {
    currentSelect = selectInput.value;
    addShow(currentSelect);
  }

})(); // close IIFE
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console