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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<select>
  <option>One</option>
  <option>Two</option>
  <option>Three</option>
  <option>Four</option>
</select>
            
          
!
            
              .selectbox {
  width: 200px;
  padding: 10px;
  border: 1px solid #ddd;
  line-height: 1em;
}

.selectbox:after {
  content: '⬇︎';
  float:right;
}

/* Fallback for mobile safari */
select.safari {
  -webkit-appearance: none;
  width: 200px;
  padding: 10px;
  border: 1px solid #ddd;
  line-height: 1em;
  background: url('https://cdn4.iconfinder.com/data/icons/defaulticon/icons/png/16x16/arrow-down.png') no-repeat 98% center;
}
            
          
!
            
              $(function() {

    var userAgent = window.navigator.userAgent;
    var isSafari = false;
    if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
        isSafari = true;
        $('select').addClass('safari');
    }

    if (!isSafari) {

        $('select').each(function() {

            // Wrap selectbox to custom structure and populate current value
            $select = $(this);
            $custom = $('<span class="selectbox"><span class="selectboxvalue"></span></span>');
            $select.after($custom);
            $custom.append($select);
            $custom.find('.selectboxvalue').text($select.find(':selected').text());

            // Define basic styles to behave like select box
            $custom.css({
                position: 'relative',
                display: 'inline-block',
                cursor: 'pointer'
            });

            $select.css({
                display: 'none',
                position: 'absolute',
                top: 0,
                left: 0,
                zIndex: 10,
                minWidth: '100%'
            });

            $select.attr('size', $select.find('option').length);


            // Define controll
            $custom.on('click', function(e) {
                $(this).find('select').show();
            });

            $select.on('click', function(e) {
                var val = $(this).find(':selected').text();
                $(this).prev('.selectboxvalue').text(val);
                $(this).hide();
                return false;
            });

        });

        // Hide select box on click outside
        $(document).click(function(e) {
            console.log(e.target);
            $('.selectbox select').hide();
            if ($(e.target).is('.selectbox')) $(e.target).find('select').show();
            if ($(e.target).is('.selectboxvalue')) $(e.target).next('select').show();
        });

    }
});
            
          
!
999px
Loading ..................

Console