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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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.

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

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.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                <form class="controls" id="Filters">
  <!-- We can add an unlimited number of "filter groups" using the following format: -->
  
  <fieldset>
    <h4>Shapes</h4>
    <div class="checkbox">
      <input type="checkbox" value=".rent"/>
      <label>For Rent</label>
    </div>
    <div class="checkbox">
      <input type="checkbox" value=".sale"/>
      <label>For Sale</label>
    </div>
    <div class="checkbox">
      <input type="checkbox" value=".shortterm"/>
      <label>Short Term</label>
    </div>
        
  </fieldset>
  
  <fieldset>
    <h4>Colours</h4>
    <div class="checkbox">
      <input type="checkbox" value=".residential"/>
      <label>Residential</label>
    </div>
    <div class="checkbox">
      <input type="checkbox" value=".office"/>
      <label>Office</label>
    </div>
    <div class="checkbox">
      <input type="checkbox" value=".land"/>
      <label>Land</label>
    </div>
  </fieldset>
  
    
  <button id="Reset">Show All</button>
</form>

<div id="Container" class="container">
  <div class="fail-message"><span>No items were found matching the selected filters</span></div>
  
  <div class="mix rent residential"><a href="https://developer.mozilla.org/"><img src="http://www.whereis-istanbul.com/En/Images/istanbul1.jpg" alt="TEST"></a></div>
  <div class="mix rent office"></div>
  <div class="mix rent land itcover">
      <div class="colorbox"></div>
      <div class="firsttext"> First Text</div>
      <div class="secondtext"> Second Text</div>
      <div class="imagearea"> IMAGE</div>
      <div class="scndprnt">
        <div class="detailfrst"> TEXT 1</div>
        <div class="detailfrst"> TEXT 2</div>
        <div class="detailfrst"> TEXT 3</div>
        <div class="detailfrst"> TEXT 4</div>
      </div>
      <div class="clear"></div>
  </div>
  <div class="mix sale residential"></div>
  <div class="mix sale office"></div>
  <div class="mix sale land"></div>
  <div class="mix shortterm residential"></div>
  <div class="mix shortterm office"></div>
  <div class="mix shortterm land"></div>
  <div class="mix shortterm residential"></div>
  <div class="mix shortterm office"></div>
  <div class="mix shortterm land"></div>
</div>
    
              
            
!

CSS

              
                * {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

body {
  background: #68b8c4;
}

.container .mix:before {
  content: '';
  display: inline-block;
  image-size: cover;
}

body,
button {
  font-family: 'Helvetica Neue', arial, sans-serif;
  color: white;
  -webkit-font-smoothing: antialiased;
}
/**
 * Form & Checkbox Styles
 */

h4 {
  font-weight: 700;
  margin-bottom: .5em;
}

label {
  font-weight: 300;
}

button {
  display: inline-block;
  vertical-align: top;
  padding: .4em .8em;
  margin: 0;
  background: #68b8c4;
  border: 0;
  color: #333;
  font-size: 16px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
}

button:focus {
  outline: 0 none;
}

.controls {
  background: #333;
  padding: 2%;
}

fieldset {
  display: inline-block;
  vertical-align: top;
  margin: 0 1em 0 0;
  background: #666;
  padding: .5em;
  border-radius: 3px;
}

.checkbox {
  display: block;
  position: relative;
  cursor: pointer;
  margin-bottom: 8px;
}

.checkbox input[type="checkbox"] {
  position: absolute;
  display: block;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  cursor: pointer;
  margin: 0;
  opacity: 0;
  z-index: 1;
}

.checkbox label {
  display: inline-block;
  vertical-align: top;
  text-align: left;
  padding-left: 1.5em;
}

.checkbox label:before,
.checkbox label:after {
  content: '';
  display: block;
  position: absolute;
}

.checkbox label:before {
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  margin-right: 10px;
  background: #ddd;
  border-radius: 3px;
}

.checkbox label:after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #68b8c4;
  opacity: 0;
  pointer-events: none;
}

.checkbox input:checked ~ label:after {
  opacity: 1;
}

.checkbox input:focus ~ label:before {
  background: #eee;
}
/**
 * Container/Target Styles
 */

.container {
  padding: 1%;
  position: relative;
  background-color: white;
}

.container:after {
  content: "";
  display: inline-block;
  width: 100%;
}

.container .mix,
.container .gap {
  width: 100px;
  display: inline-block;
  margin: 1%;
}

.container .mix {
  width: 22.6%;
  height: 400px;
  margin: 1%;
  background: white;
  display: none;
  image-size: cover;
}

.container .mix.residential {
  background: lightpink;
}

.container .mix.office {
  background: lightblue;
}

.container .mix.land {
  background: lightgreen;
}

.container .mix.sale {}

.container .mix.rent {}

.container .mix.shortterm {}
/**
 * Fail message styles
 */

.container .fail-message {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  -webkit-transition: 150ms;
  -moz-transition: 150ms;
  transition: 150ms;
}

.container .fail-message:before {
  content: '';
  display: inline-block;
  vertical-align: middle;
  height: 100%;
}

.container .fail-message span {
  display: inline-block;
  vertical-align: middle;
  font-size: 20px;
  font-weight: 700;
}

.container.fail .fail-message {
  opacity: 1;
  pointer-events: auto;
}

.container .mix {
  position: relative;
}

.container .mix a {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.container .mix img {
  max-width: 100%;
  vertical-align: top;
  max-height: 100%;
}

.itcover {
  width: 314px;
  padding: 10px;
  margin: 10px;
  border: 1px grey solid;
}

.itcover > div {
  float: left;
}

.colorbox {
  background-color: red;
  height: 50px;
  width: 50px;
  position: inherit;
  margin-right: 10px;
  margin-bottom: 10px;
}

.firsttext {
  height: 20px;
  width: calc(100% - 60px);
  position: inherit;
  line-height: 20px;
}

.secondtext {
  background-color: white;
  height: 20px;
  width: calc(100% - 60px);
  position: inherit;
  margin-top: 10px;
  line-height: 20px;
}

.imagearea {
  background-color: lightgrey;
  height: 150px;
  width: 100%;
  position: inherit;
  text-align: center;
  line-height: 150px;
}

.scndprnt {
  width: 314px;
}

.scndprnt > div {
  float: left;
}

.detailfrst {
  box-sizing: border-box;
  background-color: white;
  height: 50px;
  position: inherit;
  margin-top: 10px;
  width: 25%;
  padding-left: 5px;
  padding-right: 5px;
  line-height: 50px;
  text-align: center;
  border-right: 1px lightgrey solid;
}

.detailfrst:last-child {
  border-right: none;
}

.itcover > .clear {
  clear: both;
  float: none;
}
              
            
!

JS

              
                // To keep our code clean and modular, all custom functionality will be contained inside a single object literal called "checkboxFilter".

var checkboxFilter = {
  
  // Declare any variables we will need as properties of the object
  
  $filters: null,
  $reset: null,
  groups: [],
  outputArray: [],
  outputString: '',
  
  // The "init" method will run on document ready and cache any jQuery objects we will need.
  
  init: function(){
    var self = this; // As a best practice, in each method we will asign "this" to the variable "self" so that it remains scope-agnostic. We will use it to refer to the parent "checkboxFilter" object so that we can share methods and properties between all parts of the object.
    
    self.$filters = $('#Filters');
    self.$reset = $('#Reset');
    self.$container = $('#Container');
    
    self.$filters.find('fieldset').each(function(){
      self.groups.push({
        $inputs: $(this).find('input'),
        active: [],
		    tracker: false
      });
    });
    
    self.bindHandlers();
  },
  
  // The "bindHandlers" method will listen for whenever a form value changes. 
  
  bindHandlers: function(){
    var self = this;
    
    self.$filters.on('change', function(){
      self.parseFilters();
    });
    
    self.$reset.on('click', function(e){
      e.preventDefault();
      self.$filters[0].reset();
      self.parseFilters();
    });
  },
  
  // The parseFilters method checks which filters are active in each group:
  
  parseFilters: function(){
    var self = this;
 
    // loop through each filter group and add active filters to arrays
    
    for(var i = 0, group; group = self.groups[i]; i++){
      group.active = []; // reset arrays
      group.$inputs.each(function(){ 
        $(this).is(':checked') && group.active.push(this.value);
      });
	    group.active.length && (group.tracker = 0);
    }
    
    self.concatenate();
  },
  
  // The "concatenate" method will crawl through each group, concatenating filters as desired:
  
  concatenate: function(){
    var self = this,
		  cache = '',
		  crawled = false,
		  checkTrackers = function(){
        var done = 0;
        
        for(var i = 0, group; group = self.groups[i]; i++){
          (group.tracker === false) && done++;
        }

        return (done < self.groups.length);
      },
      crawl = function(){
        for(var i = 0, group; group = self.groups[i]; i++){
          group.active[group.tracker] && (cache += group.active[group.tracker]);

          if(i === self.groups.length - 1){
            self.outputArray.push(cache);
            cache = '';
            updateTrackers();
          }
        }
      },
      updateTrackers = function(){
        for(var i = self.groups.length - 1; i > -1; i--){
          var group = self.groups[i];

          if(group.active[group.tracker + 1]){
            group.tracker++; 
            break;
          } else if(i > 0){
            group.tracker && (group.tracker = 0);
          } else {
            crawled = true;
          }
        }
      };
    
    self.outputArray = []; // reset output array

	  do{
		  crawl();
	  }
	  while(!crawled && checkTrackers());

    self.outputString = self.outputArray.join();
    
    // If the output string is empty, show all rather than none:
    
    !self.outputString.length && (self.outputString = 'all'); 
    
    //console.log(self.outputString); 
    
    // ^ we can check the console here to take a look at the filter string that is produced
    
    // Send the output string to MixItUp via the 'filter' method:
    
	  if(self.$container.mixItUp('isLoaded')){
    	self.$container.mixItUp('filter', self.outputString);
	  }
  }
};
  
// On document ready, initialise our code.

$(function(){
      
  // Initialize checkboxFilter code
      
  checkboxFilter.init();
      
  // Instantiate MixItUp
      
  $('#Container').mixItUp({
    controls: {
      enable: false // we won't be needing these
    },
    animation: {
      easing: 'cubic-bezier(0.86, 0, 0.07, 1)',
      duration: 600
    }
  });    
});
              
            
!
999px
💕 I'm the CSS to your HTML.

Console