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

              
                 <h1>Select Element UI</h1>

    <form>
        <label for="select">City</label>
        <div class="form-select">
            <select id="select" name="city">
                <option value="">Select a city</option>
                <option value="rodez">Rodez, France</option>
                <option value="toulouse">Toulouse, France</option>
                <option value="quebec">Quebec, Canada</option>
                <option value="sydney">Sydney, Australia</option>
            </select>
        </div>
    </form>
    <p>This is an experimentation of an alternative to the default select element.</p>
    <a href="http://stevenfabre.com/" title="Steven Fabre's Website" class="social">stevenfabre.com</a>
    <a href="https://twitter.com/stevenfabre" title="Steven Fabre's Twitter" class="social">@stevenfabre</a>

              
            
!

CSS

              
                
/* Colors */
$color-white: #fff;
$color-light-green-grey: #f5fff2; /* f2fbff */
$color-text-light: #8a9487;
$color-text: lighten(#575c56, 10%);
$color-green:#5fd570;

/* Fonts */
$font-primary: 'Helvetica Neue', 'Helvetica', Arial, sans-serif;


$size-width-select: 300px;
$size-height-select: 48px;

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


body {
  background: -webkit-linear-gradient(top, $color-light-green-grey 0%, $color-white 75%) no-repeat;
  background: -moz-linear-gradient(top, $color-light-green-grey 0%, $color-white 75%) no-repeat;
  background: -ms-linear-gradient(top, $color-light-green-grey 0%, $color-white 75%) no-repeat;
  background: linear, to bottom, $color-light-green-grey 0%, $color-white 75% no-repeat;
  font-family: $font-primary;
  color:$color-text;
  font-weight:300;
  padding: 0 5%;
}


h1 {
  font-weight:100;
  font-size:5em;
  color: darken($color-green, 15%);
  text-shadow: 1px 1px 0 $color-white;
}
p {
  font-size:1.25em;
  z-index:1;
  position:relative;
  margin-top: 4em;
}

a {
  &.social {
    display:inline-block;
    color:darken($color-green, 15%);
    margin-right:1em;
  }
}

form {
  label {
    font-weight:600;
    display: inline-block;
    margin:0 0 0.5em 0;
  }
  .form-select {
    position:relative;
    width:$size-width-select;
    z-index:10;
    &:after {
      content: '▸';
      position: absolute;
      top: 0;
      right: 1em;
      z-index: 1;
      color: $color-text-light;
      line-height: $size-height-select;
      font-size: 1em;
    }
    .select {
      width:$size-width-select;
      height:$size-height-select;
      line-height:$size-height-select;
      -webkit-appearance: none;
      -moz-appearance: none;
      appearance: none;
      padding:0 1em;
      border-radius:4px;
      border:1px solid lighten($color-text-light, 30%);
      background: -webkit-linear-gradient(bottom, $color-light-green-grey -20%, $color-white 110%) no-repeat;
      background: -moz-linear-gradient(bottom, $color-light-green-grey -20%, $color-white 110%) no-repeat;
      background: -ms-linear-gradient(bottom, $color-light-green-grey -20%, $color-white 110%) no-repeat;
      background: linear, to top, $color-light-green-grey -20%, $color-white 110% no-repeat;
      color:$color-text-light;
      cursor:pointer;
      transition: all 0.4s ease;

      &:hover, &:focus {
        border-color:lighten($color-green, 15%);
        box-shadow: 0 0 5px lighten($color-green, 20%);
        outline:0;
      }
    }
    .select-options {
      display:none;
      position:absolute;
      z-index:10;
      top:0;
      left:$size-width-select;
      width:$size-width-select;
      list-style-type: none;
      margin: 0 0 0 1em;
      padding:0;
      border-radius:4px;
      border:1px solid lighten($color-text-light, 20%);
      box-shadow: 0 0 5px lighten($color-green, 30%);
      background: -webkit-linear-gradient(bottom, $color-light-green-grey 0%, $color-white 110%) no-repeat;
      background: -moz-linear-gradient(bottom, $color-light-green-grey 0%, $color-white 110%) no-repeat;
      background: -ms-linear-gradient(bottom, $color-light-green-grey 0%, $color-white 110%) no-repeat;
      background: linear, to top, $color-light-green-grey 0%, $color-white 110% no-repeat;
      color:$color-text-light;
      li {
        padding:0.5em 1em;
        cursor:pointer;
        text-shadow:1px 0px 0 $color-white;
        &:hover {
          color:$color-white;
          background:$color-green;
          text-shadow:1px 0px 0 darken($color-green, 20%);
        }
      }
      &:before {
        content: '◂';
        position: absolute;
        top: -3px;
        left: -15px;
        font-size: 38px;
      }
    }
  }
}

.hidden {
  display:none;
}
              
            
!

JS

              
                
    var selectElement = $('#select');
    var numberOfOptions = selectElement.children('option').length;

    /* Add class hidden to default select element to hide it */
    selectElement.addClass('hidden');

    selectElement.after('<div class="select"></div>');

    var selectStyled = selectElement.next('.select');
    selectStyled.text(selectElement.children('option').eq(0).text());

    var list = $('<ul />', {
        'class': 'select-options'
    }).insertAfter(selectStyled);

    for (var i = 0; i < numberOfOptions; i++) {
        $('<li />', {
            text: selectElement.children('option').eq(i).text(),
            rel: selectElement.children('option').eq(i).val()
        }).appendTo(list);
    }

    var listItems = list.children('li');

    selectStyled.click(function(e) {
        e.stopPropagation();
        $('.select.active').each(function(){
            $(this).removeClass('active').next('ul.select-options').hide();
        });
        $(this).toggleClass('active').next('ul.select-options').toggle();
    });

    listItems.click(function(e) {
        e.stopPropagation();
        selectStyled.text($(this).text()).removeClass('active');
        selectElement.val($(this).attr('rel'));
        list.hide();
    });

    $(document).click(function() {
        selectStyled.removeClass('active');
        list.hide();
    });

              
            
!
999px

Console