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

              
                <label for="foo">Select an option&hellip;</label>

<div class="select">
  <select id="foo">
    <option>Option 1</option>
    <option>Option 2</option>
    <option>Option 3</option>
  </select>
  <span class="select-value" aria-hidden="true"></span>
</div>
              
            
!

CSS

              
                /* boilerplate stuff */

html {
  background-color: #f0f0f0;
}

body {
  color: #555;
  margin: 0 auto;
  max-width: 480px;
  padding: 1em;
}

label {
  cursor: pointer;
  display: block;
  margin-bottom: 0.5em;
}

/* style the "fake" select */

.js .select {
  background-color: #fff;
  background-image: linear-gradient(to bottom, #fff, #f1f1f1);
  border: 1px solid #ccc;
  border-bottom-color: #bbb;
  border-radius: 0.25em;
  box-shadow: 0 2px 0 rgba(0,0,0,0.05);
  color: #709AD0;
  font-family: sans-serif;
  font-weight: 600;
  line-height: 1;
  padding: 0.75em 2em 0.75em 0.75em;
  position: relative;
}

.js .select::after {
  border-left: 0.375em solid transparent;
  border-right: 0.375em solid transparent;
  border-top: 0.375em solid #999;
  content: '';
  float: right;
  height: 0;
  margin-top: -0.1875em;
  position: absolute;
  right: 0.75em;
  top: 50%;
  width: 0;
}

.js .select:hover {
  border-color: #aaa;
  border-bottom-color: #999
}

.js .select.focus {
  border-color: #709AD0;
  box-shadow: 0 0 0 1px #709AD0, 0 2px 0 1px #ddd;
}

.js .select.focus::after {
  border-top-color: #709AD0;
}

/* nicer default styles for "real" <select> */
.select select {
  cursor: pointer;
  display: block;
  width: 100%;
}
/* hide and overlay when JavaScript is enabled */
.js .select select {
  left: 0;
  height: 100%;
  min-height: 100%;
  min-width: 100%;
  opacity: 0;
  position: absolute;
  top: 0;
}
              
            
!

JS

              
                // For each .select element
$('.select').each(function(){
  // Save some elements as variables
  var $element = $(this);
  var $select = $element.find('select');
  var $value = $element.find('.select-value');
  // Bind event handlers to <select>
  $select.on({
    // On change or keyup, update the value text
    'change keyup': function () {
      $value.text($select.val());
    },
    // On focus, add the focus class
    'focus': function () {
      $element.addClass('focus');
    },
    // On blur, remove the focus class
    'blur': function () {
      $element.removeClass('focus');
    }
  });
  // Trigger the change event so the value is current
  $select.trigger('change');
});
              
            
!
999px

Console