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.

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="wall">
  <a class="article" href="https://google.com">
    <img src="https://c1.staticflickr.com/1/674/20942077784_5d3ffb2ed0_h.jpg" />
    <h2>Cursus cursus proin auctor in in ac, nunc, tortor</h2>
  </a>


  <div class="article">
    <img src="https://c1.staticflickr.com/1/627/21377063080_0cff41fa68_h.jpg" />
    <h2>Cursus cursus proin auctor in in ac, nunc, tortor</h2>
  </div>



  <div class="article">
    <img src="https://c1.staticflickr.com/1/750/20951237774_c566039468_h.jpg" />
    <h2>Cursus cursus proin auctor in in ac, nunc, tortor</h2>
  </div>



  <div class="article">
    <img src="https://c2.staticflickr.com/6/5628/21386436100_0cff0854b5_h.jpg" />
    <h2>Cursus cursus proin auctor in in ac, nunc, tortor</h2>
  </div>



  <div class="article">
    <img src="https://c1.staticflickr.com/1/710/21536720606_beb3fccf81_h.jpg" />
    <h2>Cursus cursus proin auctor in in ac, nunc, tortor</h2>
  </div>



  <div class="article">
    <img src="https://c2.staticflickr.com/6/5753/20943258253_28a1520687_h.jpg" />
    <h2>Cursus cursus proin auctor in in ac, nunc, tortor</h2>
  </div>
</div>
              
            
!

CSS

              
                *{margin:0; padding:0;}

body{
  font-family:sans-serif;
  margin: 24px;
  background:#f0f0f0;
  color:#505050;
}

a{text-decoration:none; color:black;}

.article{
  display:block;
  margin: 0 0 30px 0;
  
  padding:12px;
  background:white;
  border-radius: 3px;
  box-shadow: 0px 1px 2px 0px rgba(black,0.05);
  transition:all 220ms;
  
  &:hover{
    box-shadow: 0px 2px 3px 1px rgba(black,0.1);
    transform : translateY(-5px);
    transition:all 220ms;
  }
  
  >img{
    display:block;
    width:100%;
    margin: 0 0 24px 0;
  }
  h2{
    text-align:center;
    font-size:14px;
    text-transform:uppercase;
    margin: 0 0 12px 0;
  }
}

.wall{
  display:block;
  position:relative;
  &-column{
    display:block;
    position:relative;
    width:33.333333%;
    float:left;
    padding: 0;
    box-sizing:border-box;
    
    &:first-child{
      padding-right:12px;
    }
    & ~.wall-column{
      padding-left:12px;
      padding-right:12px;
    }
    &:last-of-type{
      padding-right:0;
    }
    
    @media (max-width:640px){
      width:50%;
    }
    
    @media (max-width:480px){
      width:auto;
      float:none;
      padding:0;
    }
    
  }
}
              
            
!

JS

              
                /*
JALISWALL 0.3
by Pierre Bonnin - @PierreBonninPRO - 2015
*/
(function($){
  $.fn.jaliswall = function(options){
    
    this.each(function(){
      
      var defaults = {
        item : '.wall-item',
        columnClass : '.wall-column',
        resize:true,
        onChange : function(){void(0);}
      }
      
      var prm = $.extend(defaults, options);
      
      var container = $(this);
      var items = container.find(prm.item);
      var elemsDatas = [];
      var columns = [];
      var nbCols = getNbCols();
      
      init();
      
      function init(){
        nbCols = getNbCols();
        recordAndRemove();
        print();
        if(prm.resize){
          $(window).resize(function(){
            if(nbCols != getNbCols()){
              nbCols = getNbCols();
              setColPos();
              print();
            }
          });
        }
      }
      
      function getNbCols(){
        var instanceForCompute = false;
        if(container.find(prm.columnClass).length == 0){
          instanceForCompute = true;
          container.append("<div class='"+parseSelector(prm.columnClass)+"'></div>");
        }
        var colWidth = container.find(prm.columnClass).outerWidth(true);
        var wallWidth = container.innerWidth();
        if(instanceForCompute)container.find(prm.columnClass).remove();
        return Math.round(wallWidth / colWidth);
      }
      
      // save items content and params and removes originals items
      function recordAndRemove(){
        items.each(function(index){
          var item = $(this);
          elemsDatas.push({
            content : item[0].outerHTML,
            colid : index%nbCols
          });
          item.remove();
        });
      }
      
      //determines in which column an item should be
      function setColPos(){
        for (var i in elemsDatas){
          elemsDatas[i].colid = i%nbCols;
        }
      }
      
      // to get a class name without the selector
      function parseSelector(selector){
        return selector.slice(1, selector.length);
      }
      
      //write and append html
      function print(){
        var tree = '';
        //creates columns
        for (var i=0; i<nbCols; i++){
          tree += "<div class='"+parseSelector(prm.columnClass)+"'></div>";
        }
        container.html(tree);
        
        // creates items
        for (var i in elemsDatas){
          var html='';
          
          var content = (elemsDatas[i].content != undefined)?elemsDatas[i].content:'';
          html += content;
          container.children(prm.columnClass).eq(i%nbCols).append(html);
        }
        
        try{
          prm.onChange();
        }catch(e){
          console.log('jaliswall onChange error / '+e);
        }
        
      }
      
      //creates a well-formed attribute
      function getAttr(attr, type){
        return (attr != undefined)?type+"='"+attr+"'":'';
      }
      
    });
    
    return this;
  }
})(jQuery);




function onChange(){
  console.log('cols number changed');
}

$('.wall').jaliswall({item:'.article', onChange:onChange});
              
            
!
999px

Console