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

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

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="hint">
  <h1>Multiple items selection</h1>
  <p>You can select items individually but can also select them by clicking and moving your mouse up and down.</p>
</div>

<ul class="list">
  <li class="list--item">
    <input type="checkbox" />
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  </li>
  
  <li class="list--item">
    <input type="checkbox" />
    Aenean sit amet laoreet arcu, ac mollis nibh.
  </li>
  
  <li class="list--item">
    <input type="checkbox" />
    Duis rutrum dolor eget lobortis aliquam.
  </li>
  
  <li class="list--item">
    <input type="checkbox" />
    Sed faucibus aliquam sem, et sagittis sapien aliquet nec.
  </li>
  
  <li class="list--item">
    <input type="checkbox" />
    Morbi ullamcorper non lorem eu ullamcorper.
  </li>
  
  <li class="list--item">
    <input type="checkbox" />
    Quisque eu dignissim neque, eu lobortis neque.
  </li>
  
  <li class="list--item">
    <input type="checkbox" />
    Phasellus quis fringilla ante, in viverra mauris.
  </li>
  
  <li class="list--item">
    <input type="checkbox" />
    In sagittis semper cursus.
  </li>
  
  <li class="list--item">
    <input type="checkbox" />
    Cras dolor felis, congue sit amet dapibus eu, semper eget erat.
  </li>
</ul>
            
          
!
            
              @import compass

@import compass/css3
@import compass/css3/user-interface

$margin: 20px

body
  margin: $margin
  background: gainsboro
  font-family: Helvetica, Arial, sans-serif
  
.list
  width: 99%
  padding: 0
  margin: 0
  +user-select(none)
  
.list--item
  width: inherit
  cursor: pointer
  list-style: none
  padding: 15px
  margin: 0
  color: black
  background: white
  border-left: 3px solid transparent
  &:not(:last-child)
    border-bottom: 1px solid rgba(0, 0, 0, .25)
  &.is-active
    border-left: 3px solid royalblue
    background: lightyellow

  +transition-duration(.2s)
  +transition-property(border)

input[type=checkbox]
  cursor: pointer
  margin-right: 10px
  
.hint
  > h1
    font-size: 2em
    letter-spacing: -2pt
    margin-bottom: 10px
      
  display: block
  cursor: help
  margin-bottom: 40px
            
          
!
            
              /**
 * Interaction study for multiple items selection.
 * You can select items individually but can also select them by clicking and moving your mouse up and down.
 * This is something I miss a lot on Gmail's web interface.
 * @author Rafael Rinaldi (rafaelrinaldi.com)
 * @date 2013-09-25
 */
(function( $ ) {
  
  // Is user selecting items?
  var _isSelecting = false;
  
  function init() {
    
    // Listening for mouse events on <ul />
    $('.list')
      .mouseover(_listMouseOver)
      .mouseleave(_listMouseLeave)
      .mouseup(_listMouseUp)
      .mousedown(_listMouseDown);
    
    // To handle component style based on :checked
    $('input[type=checkbox]').click(_checkboxClick);
    
  }
  
  function _listMouseDown( event ) {
    event.preventDefault();
    event.stopPropagation();
    
    var target = $(event.target),
        checkbox = target.find('input[type=checkbox]');
    
    _isSelecting = true;
    
    checkbox.prop('checked', !checkbox.is(':checked'));
    
    target.toggleClass('is-active');
  }
  
  function _listMouseUp( event ) {
    event.preventDefault();
    event.stopPropagation();
    _isSelecting = false;
  }
  
  function _listMouseOver( event ) {
    event.preventDefault();
    event.stopPropagation();
    
    if(_isSelecting) {
      _listMouseDown(event);
    }
  }
  
  function _listMouseLeave( event ) {
    event.preventDefault();
    event.stopPropagation();
    _isSelecting = false;
  }
  
  function _checkboxClick( event ) {
    event.stopPropagation();
    
    var target = $(event.currentTarget);
    
    if(target.is(':checked')) {
      target.parent('li').addClass('is-active');
    } else {
      target.parent('li').removeClass('is-active');
    }
  }
  
  init();
  
})(Zepto);
            
          
!
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.

Console