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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <div id="form-ui">
<p>
  <select>
    <option value="">–Select price–</option>
    <option value=".price10">$10</option>
    <option value=".price20">$20</option>
    <option value=".price30">$30</option>
  </select>
  
  <select>
    <option value="">–Select size–</option>
    <option value=".small">small</option>
    <option value=".medium">medium</option>
    <option value=".large">large</option>
  </select>

  

  </p>

<p>
  <label><input type="checkbox" value=".red" /> red</label>
  <label><input type="checkbox" value=".green" /> green</label>
  <label><input type="checkbox" value=".blue" /> blue</label>
  <label><input type="checkbox" value=".orange" /> orange</label>
</p>

  <p id="output">--</p>
  
</div>

<div id="container">
  <!-- items added with JS -->
</div>
            
          
!
            
              * {  box-sizing: border-box; }

body { font-family: sans-serif; }

.item {
  width: 100px;
  height: 100px;
  float: left;
  
  margin: 5px;
  padding: 5px;
}

.item p {
  margin: 0;
}

.red { background: #F33; }
.blue { background: #88F; }
.green { background: #3A3; }
.orange { background: orange;}

select, label, input { font-size: 20px; }

label { margin-right: 10px; }
            
          
!
            
              
createItems();

var $container = $('#container').isotope({
  itemSelector: '.item'
});

var $output = $('#output');

// filter with selects and checkboxes
var $selects = $('#form-ui select');
var $checkboxes = $('#form-ui input');

$selects.add( $checkboxes ).change( function() {
  // map input values to an array
  var exclusives = [];
  var inclusives = [];
  // exclusive filters from selects
  $selects.each( function( i, elem ) {
    if ( elem.value ) {
      exclusives.push( elem.value );
    }
  });
  // inclusive filters from checkboxes
  $checkboxes.each( function( i, elem ) {
    // if checkbox, use value if checked
    if ( elem.checked ) {
      inclusives.push( elem.value );
    }
  });

  // combine exclusive and inclusive filters

  // first combine exclusives
  exclusives = exclusives.join('');

  var filterValue;
  if ( inclusives.length ) {
    // map inclusives with exclusives for
    filterValue = $.map( inclusives, function( value ) {
      return value + exclusives;
    });
    filterValue = filterValue.join(', ');
  } else {
    filterValue = exclusives;
  }

  $output.text( filterValue );
  $container.isotope({ filter: filterValue })
});


function createItems() {

  var colors = [ 'red', 'green', 'blue', 'orange' ];
  var sizes = [ 'small', 'medium', 'large' ];
  var prices = [ 10, 20, 30 ];

  
  var $items;
  // loop over colors, sizes, prices
  // create one item for each
  for (  var i=0; i < colors.length; i++ ) {
    for ( var j=0; j < sizes.length; j++ ) {
      for ( var k=0; k < prices.length; k++ ) {
        var color = colors[i];
        var size = sizes[j];
        var price = prices[k];
        var $item = $('<div />', {
          'class': 'item ' + color + ' ' + size + ' price' + price
        });
        $item.append( '<p>' + size + '</p><p>$' + price + '</p>');
        // add to items
        $items = $items ? $items.add( $item ) : $item;
      }
    } 
  }

  $items.appendTo( $('#container') );

}

            
          
!
999px
Loading ..................

Console