Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <small style="width:400px; margin: 20px auto;">This method uses radio buttons to record user input. To navigate by keyboard, focus the button and press enter to open dropdown, tab through the dropdown items & press enter to select option. Visit <a href="https://btn.ninja" target="_blank">btn.ninja</a> for more.</small> 

<div class="dropdown" style="width:200px; margin:20px auto;">
	<button type="button" class="btn btn-light dropdown-toggle" data-toggle="dropdown">
	  	<ins>Press this Button</ins>
	</button>
	<div class="dropdown-menu radio">

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="001" name="alphabet">
        <i>Alpha</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="002" name="alphabet">
        <i>Bravo</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="003" name="alphabet">
        <i>Charlie</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="004" name="alphabet">
        <i>Delta</i>
        </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="005" name="alphabet">
        <i>Echo</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="006" name="alphabet">
        <i>Foxtrot</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="007" name="alphabet">
        <i>Golf</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="008" name="alphabet">
        <i>Hotel</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="009" name="alphabet">
        <i>India</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="010" name="alphabet">
        <i>Juliette</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="011" name="alphabet">
        <i>Kilo</i>
      </label>

    	<label class="dropdown-item">
        <input class="jRadioDropdown" type="radio" value="012" name="alphabet">
        <i>Lima</i>
      </label>

	</div>
</div>

              
            
!

CSS

              
                .dropdown-menu.radio .dropdown-item { 
	position:relative;
	overflow:hidden; 
	cursor:pointer; }

.dropdown-menu.radio input { 
	visibility: hidden; 
	position:absolute; left: -30px; }

.dropdown-menu.radio i { 
	font-weight:normal; font-style:normal; 
	display:block; }

.dropdown-item.active {
  background-color:#555; color:#fff;
}

              
            
!

JS

              
                // OPTIONAL JS

// Change the button text & add active class
$('.jRadioDropdown').change(function() {
  var dropdown = $(this).closest('.dropdown');
  var thislabel = $(this).closest('label');

  dropdown.find('label').removeClass('active');
  if( $(this).is(':checked') ) {
    thislabel.addClass('active');
    dropdown.find('ins').html( thislabel.text() );
  }

});    
 
//Add tabindex on labels
$('label.dropdown-item').each(function (index, value){
  $(this).attr('tabindex', 0 );
  $(this).find('input').attr('tabindex', -1 );
});

//Add keyboard navigation
$('label.dropdown-item').keypress(function(e){
  if((e.keyCode ? e.keyCode : e.which) == 13){
    $(this).trigger('click');
  }
});
              
            
!
999px

Console