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

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 id="container">
  <!-- Masonry contents -->
  <div id="mnsry_container">
    <article class="big">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/630/630?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/630/630?random');">
          <h1>Mamie Lucas</h1>
        </div>
      </div>
    </article>
    <article class="wide">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/700/350?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/700/350?random');">
          <h1>Mercedes Watson</h1>
        </div>
      </div>
    </article>
    <article class="small">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/500/500?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/500/500?random');">
          <h1>Alberta	 Poole</h1>
        </div>
      </div>
    </article>
    <article class="small">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/450/450?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/450/450?random');">
          <h1>Yolanda Mcdaniel</h1>
        </div>
    </article>
    <article class="small">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/520/520?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/520/520?random');">
          <h1>Violet Miller</h1>
        </div>
      </div>
    </article>
    <article class="long">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/680/340?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/680/340?random');">
          <h1>Tony 	Ortiz</h1>
        </div>
      </div>
    </article>
    <article class="long">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/720/360?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/720/360?random');">
          <h1>Cora 	Doyle</h1>
        </div>
      </div>
    </article>
    <article class="wide">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/800/400?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/800/400?random');">
          <h1>Clifton	 Jefferson</h1>
        </div>
      </div>
    </article>
    <article class="small">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/640/640?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/640/640?random');">
          <h1>Stephen	 Reid</h1>
        </div>
      </div>
    </article>
    <article class="small">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/660/660?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/660/660?random');">
          <h1>Myra	 Wright</h1>
        </div>
      </div>
    </article>
    <article class="small">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/600/600?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/600/600?random');">
          <h1>Rosemary	 Warren</h1>
        </div>
      </div>
    </article>
    <article class="wide">
      <div class="item">
        <div class="item-img" style="background-image:url('https://unsplash.it/750/375?random');"></div>
        <div class="item-content" style="background-image:url('https://unsplash.it/750/375?random');">
          <h1>Francisco	 Hamilton</h1>
        </div>
      </div>
    </article>
  </div>
 </div>

<!--Loading message -->
<div id="loading_msg">Loading...</div>
              
            
!

CSS

              
                $bg_color:#333;
$fonts:Arial, "Hiragino Kaku Gothic Pro W3", Meiryo, sans-serif;
$font_color:#fff;
$link_color:#ccc;
$link_hover_color:#aaa;

*, *:before, *:after{
  box-sizing:border-box;
  padding:0;
  margin:0;
}
body{
  font-family:$fonts;
  background-color:$bg_color;
  color: $font_color;
  text-align: center;
  a, a:visited{
    color: $link_color;
    text-decoration:none;
  }
  a:hover{
    color: $link_hover_color;
  }
}

// SCSS Extend Styles
%flip-style{
  position:absolute;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background-size: cover;
  background-position:50%;
  -webkit-backface-visibility:hidden;
  backface-visibility:hidden;
}

// Main container
#container{
  width:960px;
  margin:0 auto;
}

// Masonry container
#mnsry_container{
  position:relative;
  
  // Each masonry item
  article{
    width:192px;
    height:192px;
    cursor:pointer;
    -webkit-perspective:1600px;
    perspective:1600px;
    opacity:0;
 
    // Big size
    &.big{
      width:384px;
      height:384px;
      -webkit-perspective:2400px;
      perspective:2400px;
    }
    
    // Long size
    &.long{
      height:384px;
      -webkit-perspective:2000px;
      perspective:2000px;
    }
    
    // Wide size
    &.wide{
      width:384px;
      -webkit-perspective:2000px;
      perspective:2000px;
    }
    
    .item{
      height:100%;
      transform-style:preserve-3d;
      transition:all .4s;
      -webkit-transition:-webkit-transform .4s;
    }
    
    // Forward image
    .item-img{
      @extend %flip-style
    }
    
    // Behind image (including article content)
    .item-content{
      @extend %flip-style;
      -webkit-transform:rotateX(180deg);
      transform:rotateX(180deg);
      
      // Overlay flip
      &:before{
        @extend %flip-style;
        content:"";
        background-color:rgba(#FF7D40, 0.84);
      }
      
      // Article title
      h1{
        position:absolute;
        top:46%;
        left:0;
        width:100%;
        font-size:18px;
      }
    }

    &:hover{
      z-index:10;
      .item{
        // Show .item-content and rotate to 0 degree
        -webkit-transform: rotateX(-180deg);
        transform: rotateX(-180deg);
      }
    }
  }
}

// Loading message
#loading_msg{
  position:fixed;
  top:48%;
  width:100%;
  z-index:-1;
}

// Mediaqueries
@media ( max-width : 860px ){
  #container{
    width:100%;
  }
  // set to 2 column
  #mnsry_container{
    article,
    article.big,
    article.long,
    article.wide{
      width:50%;
      min-height:180px;
    }
  }
}
@media ( max-width : 667px ){
  // set to 1 column
  #mnsry_container{
    article,
    article.big,
    article.long,
    article.wide{
      width:100%;
      min-height:220px;
    }
  }
}
              
            
!

JS

              
                // Params
var j$ = jQuery,
    $mContainer = j$("#mnsry_container"),
    $loadingMessage = j$("#loading_msg");
    $params = {
      itemSelector: "article",
      columnWidth:"article.small"
    };

// After the page is loaded
j$(window).load(function() { 
  // Do mansonry with filtering 
  $mContainer.masonry($params);
  // Show articles with fadein
  $mContainer.find("article").animate({
      "opacity":1
    }, 1200);
  // Hide loading message
  $loadingMessage.fadeOut();
});
              
            
!
999px

Console