cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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.

            
               <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>

            
          
!
            
              
/* 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;
}
            
          
!
            
              
    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
🕑 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.
Loading ..................

Console