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

              
                 <!--
   The following is a common layout you would see in an email client.
   When a user clicks a checkbox, holds Shift, and then clicks another checkbox a few rows down, all the checkboxes inbetween those two checkboxes should be checked.
  -->
<h1>Check Multiple Checkboxes</h1> 
<h2>Check one item, hold down SHIFT, check another item</h2>

  <div class="inbox post-it-note">
    <div class="item">
      <input type="checkbox">
      <p>Message</p>
    </div>
    <div class="item">
      <input type="checkbox">
      <p>Message</p>
    </div>
    <div class="item">
      <input type="checkbox">
      <p>Message</p>
    </div>
    <div class="item">
      <input type="checkbox">
      <p>Message</p>
    </div>
    <div class="item">
      <input type="checkbox">
      <p>Message</p>
    </div>
    </div>
  </div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Exo");

html {
  background-color: #00acc1;
  font-family: 'Exo', sans-serif;
}
h1 {
  text-align: center;
  font-size: 32px;
}
h2{
  text-align: center;
  font-size: 18px;
  font-weight: 400;
}
.inbox {
  max-width:400px;
  margin:50px auto;
  background:white;
  border-radius:5px;
  box-shadow:10px 10px 0 rgba(0,0,0,0.1);
}

.post-it-note {
  padding: 2em;
  background: #ffd707;
  position: relative;
  min-height: 10em;
}

.post-it-note:after {
  content: "";
  position: absolute;
  bottom: -2em;
  left: 0;
  right: 2em;
  border-width: 1em;
  border-style: solid;
  border-color: #ffd707;
}

.post-it-note:before {
  content: "";
  position: absolute;
  bottom: -2em;
  right: 0;
  border-width: 2em 2em 0 0;
  border-style: solid;
  border-color: #d3b100 transparent;
}

.item {
  display:flex;
  align-items:center;
  border-bottom: 1px solid #F1F1F1;
}
.item:last-child {
  border-bottom:0;
}
input:checked + p {
  background: #ffd707;
  text-decoration: line-through;
}
input[type="checkbox"] {
  margin:20px;
}
p {
  margin:0;
  padding:20px;
  transition:background 0.2s;
  flex:1;
  font-family:'helvetica neue';
  font-size: 20px;
  font-weight: 200;
  border-left: 1px solid #D1E2FF;
}
              
            
!

JS

              
                const checkboxes = document.querySelectorAll('.inbox input[type="checkbox"]');
let lastChecked;
function handleCheck(e) {
  // Check if they had the shift key down
  // AND check that they are checking it
  let inBetween = false;
  if (e.shiftKey && this.checked) {
    // go ahead and do what we please
    // loop over every single checkbox
    checkboxes.forEach(checkbox => {
      console.log(checkbox);
      if (checkbox === this || checkbox === lastChecked) {
        inBetween = !inBetween;
        console.log('Starting to check them inbetween!');
      }
      if (inBetween) {
        checkbox.checked = true;
      }
    });
  }
  lastChecked = this;
}
checkboxes.forEach(checkbox => checkbox.addEventListener('click', handleCheck));
              
            
!
999px

Console