Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource


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


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.


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.


                <header class="container">
  <h1 class="element-stack">Pinterest Flow</h1>
  <p class="element-stack">Refresh to load a new set of data.</p>
<div class="container container-masonry"></div>

<script id="item-template" type="text/x-handlebars-template">
	{{#each items}}
  <div class="item">
  	<div class="element-stack">
    	<img class="item-image" src="{{image}}" alt="" />
    <div class="item-info">
    	<div class="item-pin-count element">
      	<i class="fa fa-thumb-tack" aria-hidden="true"></i>
      <div class="element-stack">
      	<h3 class="item-title">{{title}}</h3>
     	 	<div class="item-source">{{source}}</div>
      <div class="item-user element-stack">
      	<div class="item-avatar" style="background-image: url({{avatar}});"></div>
        <div class="item-user-info">
        	<div class="item-username">{{name}}</div>
          <div class="item-tagline">{{tagline}}</div>


                $gutter: 20px;
$itemWidth: 236px;
$titelWidth: 145px;
$borderRadius: 6px;
$avatarSize: 24px;

body {
  font-family: "Helvetica Neue", Helvetica, "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", メイリオ, Meiryo, "MS Pゴシック", arial, sans-serif;
  font-size: 11px;
  line-height: 12px;

header {
  border-bottom: 1px solid #e1e1e1;

h1 {
  font-size: 20px;
  line-height: 1;
  font-weight: bold;
  color: #444;

.container {
  margin: 0 auto;

.element {
  padding: $gutter / 2;

.element-stack {
  padding: 0 ($gutter / 2);
  margin: ($gutter / 2) 0;

.item {
  width: $itemWidth + $gutter;
  border-radius: $borderRadius;
  cursor: pointer;
  &:hover {
    background: #f3f3f3;

.item-image {
  display: block;
  border-radius: $borderRadius;

.item-info {
  position: relative;

.item-pin-count {
  position: absolute;
  top: 0;
  right: 0;
  padding-top: 0;
  color: #a7a7a7;
  font-weight: bold;

.item-source {
  max-width: $titelWidth;

.item-title {
  color: #444;
  font-size: 14px;
  line-height: 16px;
  font-weight: bold;

.item-source {
  color: #b5b5b5;
  font-size: 11px;
  line-height: 12px;
  font-weight: bold;

.item-user-info {
  display: inline-block;
  vertical-align: middle;
  color: #555;

.item-avatar {
  background-color: #ccc;
  background-size: cover;
  width: $avatarSize;
  height: $avatarSize;
  border-radius: 50%;
  margin-right: 8px;

.item-username {
  font-weight: bold;


  var demo = {
    defaultOptions: {
      $container: $('.container-masonry'),
      $template: $('#item-template'),
      gutter: 20,
      imgWidth: 236,
      itemSelector: '.item',
      count: 20,
    options: {},
    items: [],
    init: function(options) {
      var self = this;
      self.options = $.extend({}, self.defaultOptions, options);
      self.getData(self.options.count, function(){
        var $container = self.options.$container;
        var html = self.generateHtml(self.options.$template, self.items);
    getData: function(count, callback) {
      for (var i = 0; i < count; i++) {
        var imageHeight = this.getRandomIntInclusive(10, 45) * 10;
          image: ''+this.options.imgWidth+'/'+imageHeight+'/?random',
          title: faker.lorem.sentence(),
          pinCount: this.getRandomIntInclusive(1, 999),
          avatar: faker.image.avatar(),
      if (callback) callback();
    generateHtml: function($selector, items) {
      var source   = $selector.html();
      var template = Handlebars.compile(source);
      return template({items: items});
    startMasonry: function($container) {
        itemSelector: this.options.itemSelector,
        columnWidth: this.options.itemWidth +  this.options.gutter,
        fitWidth: true,
    loadImageMasonry: function($container) {
      $container.imagesLoaded().progress(function() {
    getRandomIntInclusive: function (min, max) {
      min = Math.ceil(min);
      max = Math.floor(max);
      return Math.floor(Math.random() * (max - min + 1)) + min;