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

              
                <div class="container">
  <h1>Select-all &amp; interactive selectors</h1>
  <p>Independent select-all checkbox feature with minimal jQuery, mirrored selection boxes and show/hide selection box with sizing animation.</p>
  
  <div class="controls">
    <p>These selection boxes mirror the behavior of the "Status" and "Role" selection boxes below.</p>
    <select class="a-select status-selector">
      <option>-- Status --</option>
      <option>Locked</option>
      <option>Unlocked</option>
    </select>
    <select class="a-select role-selector">
      <option>-- Role --</option>
      <option>Role 1</option>
      <option>Role 2</option>
      <option>Role 3</option>
    </select>

    &nbsp; &nbsp; &nbsp;
    <span style="whitespace: nowrap;">
      <select class="a-select status-selector">
        <option>-- Status --</option>
        <option>Locked</option>
        <option>Unlocked</option>
      </select>
    
      <select class="a-select role-selector">
        <option>-- Role --</option>
        <option>Role 1</option>
        <option>Role 2</option>
        <option>Role 3</option>
      </select>
    </span>

    <br /><br />
    <p>Selector show/hide</p>
    <div class="bulk-options-container">
      <select class="a-select bulk-actions">
        <option>-- Choose Action --</option>
        <option value="changeStatus">Change Status</option>
        <option value="addRoles">Add Roles</option>
        <option value="removeRoles">Remove Roles</option>
      </select>
      <select class="a-select bulk-options" id="changeStatus">
        <option>-- Choose Status --</option>
        <option>Locked</option>
        <option>Unlocked</option>
      </select>
      <div class="bulk-options roles-container" id='addRoles'>
        <p>Choose roles to add:</p>
        <label>
          <input type="checkbox"> Role 1
        </label>
        <label>
          <input type="checkbox"> Role 2
        </label>
        <label>
          <input type="checkbox"> Role 3
        </label>
      </div>
      <div class="bulk-options roles-container" id="removeRoles">
        <p>Choose roles to remove:</p>
        <label>
          <input type="checkbox"> Role 1
        </label>
        <label>
          <input type="checkbox"> Role 2
        </label>
        <label>
          <input type="checkbox"> Role 3
        </label>
      </div>
    </div>
  </div>
  

  <h2>Table 1</h2>
  <select class="a-select status-selector">
    <option>-- Status --</option>
    <option>Locked</option>
    <option>Unlocked</option>
  </select>
  <select class="a-select role-selector">
    <option>-- Role --</option>
    <option>Role 1</option>
    <option>Role 2</option>
    <option>Role 3</option>
  </select>
  <table>
    <thead>
      <tr>
        <th class="selector"><input type="checkbox" class="select-all"></th>
        <th>Label</th>
        <th>Label</th>
        <th>Label</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
    </tbody>
  </table>
  
  <h2>Table 2</h2>
  <table>
    <thead>
      <tr>
        <th class="selector"><input type="checkbox" class="select-all"></th>
        <th>Label</th>
        <th>Label</th>
        <th>Label</th>
        <th>Label</th>
        <th>Label</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
      <tr>
        <td class="selector"><input type="checkbox"></td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
      </tr>
    </tbody>
  </table>
  
</div>
              
            
!

CSS

              
                * {
  margin:0; 
  padding: 0;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
*:before,
*:after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
body {
  font-family: 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #444;
}
h2 {padding-top: 10px;}

.container {
  width: 100%;
  max-width: 820px;
  min-width: 300px;
  margin: 0 auto;
  padding: 20px 10px;
}

.controls {
  padding: 20px;
  margin: 20px 0;
  border: 1px solid #e0e0e0;
  background-color: #fafafa;
}

hr {
  margin: 20px 0;
  border: 0;
  border-top: 1px solid #dadada;
}

.a-select {
  border: thin solid #bbb;
  color: #444;
  padding: 5px 8px;
  margin:10px 0;
}

.bulk-options-container {
  height:50px;
  -webkit-transition: height .5s ease-in-out;
  -moz-transition:    height .5s ease-in-out;
  -ms-transition:     height .5s ease-in-out;
  -o-transition:      height .5s ease-in-out;
  transition:         height .5s ease-in-out;
}
.bulk-options {
  overflow: hidden;
}

.roles-container {
  padding: 20px;
  border: 1px solid #e0e0e0;
  background-color: #f4f4f4;
  > p {
    padding-bottom: 10px;
  }
  > label {
    padding: 0 10px;
  }
}

table {
  width: 100%;
  border: 1px solid #ddd;
  border-top: 0;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 14px;
  > thead,
  > tbody {
    > tr {
      > th,
      > td {
        padding: 6px 8px;
        vertical-align: top;
      }
    }
  }
}
table > thead {background-color: #fcb3b3; color: #8a3333;}
th {text-align: left; border: 1px solid #de8e8e;}
td {border: 1px solid #f0f0f0;}

table > tbody > tr:nth-child(odd) {
  background-color: #f9f9f9;
}

th.selector, td.selector {
  width: 20px;
  text-align: center;
}
              
            
!

JS

              
                $( document ).ready(function() {
  $('.bulk-options').hide();
});

// Select All Checkbox Functionality
$('.select-all').click( function () {
  $(this).closest('table').find(':checkbox').prop('checked', this.checked);
});

// Mirror Status Selectors
$('.status-selector').change( function () {
  $('.status-selector').val($(this).val());
})

// Mirror Role Selectors
$('.role-selector').change( function () {
  $('.role-selector').val($(this).val());
})

// Show/Hide elements based on bulk-actions selection
$('.bulk-actions').change( function () {
  var selection = $(this).val();
  
  $('.bulk-options').fadeOut();
    $('#' + selection).delay( 400 ).fadeIn();
  
  if (selection == "addRoles" || selection == "removeRoles") {
    $('.bulk-options-container').css({"height" : "150px"});
  } else {
    $('.bulk-options-container').css({"height" : "50px"});
  }
  
})
              
            
!
999px

Console