Pen Settings

HTML

CSS

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

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

Auto Save

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="wrapper">

  <!--
  ==================
  ==================
  Header
  ==================
  ==================
  -->
  <header>
    <div class="logo">
      <img src="http://tobiasbogliolo.com/assets/imgs/grama-about.png" alt="">
    </div>
    <div class="title">
      <h1>Grid & Pictures</h1>
      <h3>Tobías Bogliolo Photography</h3>
    </div>
    <nav>
      <ul>
        <li><a href="http://tobiasbogliolo.com/" target="_blank">Web</a></li>
        <li><a href="https://codepen.io/tobiasdev/" target="_blank">Codepen</a></li>
        <li><a href="http://cargocollective.com/bogliolo/Pattern-light-color" target="_blank">Cargo</a></li>
      </ul>
    </nav>
  </header>


  <!--
  ==================
  ==================
  Gallery
  ==================
  ==================
  -->
  <div class="grid">
    <!-- Optional preloaded items -->
    <!-- <div class="item"><img src="my-img.jpg" class="img-item" /></div> -->
  </div>


  <!--
  ==================
  ==================
  Footer
  ==================
  ==================
  -->
  <footer>
    <button class="append-button">Append items</button>
    <span class="status">No more items!</span>
  </footer>


  <!--
  ==================
  ==================
  Lightbox
  ==================
  ==================
  -->
  <div class="sandbox">
    <div class="lightbox"></div>
  </div>

</div>


<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Playfair+Display:400,700,900" rel="stylesheet">

              
            
!

CSS

              
                /* Color presets */
:root {
  --color-red: #FF5051;
  --color-darckgrey: #212121;
  --color-lightgrey: #E0E0E0;
  --color-black: #000000;
  --color-white: #FFFFFF;
}

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

html {
  overflow-y:scroll; /* Force scrollbar. */
}

body {
  margin: 0;
  font-family: 'Open Sans', sans-serif;
  color: var(--color-darckgrey);
}

.wrapper {
  padding: 30px 10%;
  transition: ease .2s;
}

/* Header */
header {
  margin-bottom: 80px;
  text-align: center;
}

header .logo img {
  width: 110px;
}

header .title h1 {
  margin: .2em;
  font-family: 'Playfair Display', serif;
  font-size: 2.1em;
  font-weight: normal;
}

header .title h3 {
  margin: 0;
  font-size: .9em;
  font-weight: normal;
  letter-spacing: .1em;
}

header nav ul {
  list-style: none;
  padding: 0;
}

header nav ul li {
  display: inline-block;
}

header nav ul li a {
  position: relative;
  padding: .25em .5em;
  color: var(--color-lightgrey);
  font-size: 1em;
  text-decoration: none;
}

header nav ul li a:hover:after {
  content: '';
  display: block;
  width: 100%;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  -o-transform: translateY(-50%);
  transform: translateY(-50%);
  position: absolute;
  top: 50%;
  left: 0;
  border-bottom: 4px solid var(--color-red);
}

/* Grid */
.grid {
  max-width: 1200px;
  margin: 0 auto;
}

/* Clearfix */
.grid:after {
  content: '';
  display: block;
  clear: both;
}

/* Grid items */
.item {
  display: inline-block;
  position: relative;
  width: 26%;
  margin: 20px 3.5%;
  margin-bottom: 80px;
  background: var(--color-red);
  cursor: pointer;
  /* Animation */
  animation-name: append-item;
  animation-duration: 0.6s;
  animation-iteration-count: 1;
  animation-direction: alternate;
  animation-timing-function: cubic-bezier(.42,.97,.52,1.49);
}

@keyframes append-item {
  0%  {
    -webkit-transform: translateY(250px);
    -ms-transform: translateY(250px);
    -o-transform: translateY(250px);
    transform: translateY(250px);
  }
  100%  {
    -webkit-transform: translateY(0px);
    -ms-transform: translateY(0px);
    -o-transform: translateY(0px);
    transform: translateY(0px);
  }
}

.item img {
  display: block;
  width: 100%;
  max-width: 100%;
}

.item-mid {
  width: 59%;
}

.item-big {
  width: 92%;
}

@media screen and (max-width: 768px){
  .item,
  .item-mid {
    width: 45%;
    margin: 15px 2.5%;
  }

  .item-big {
    width: 95%;
  }
}

@media screen and (max-width: 520px){
  .item,
  .item-mid,
  .item-big {
    width: 100%;
    margin: 15px 0%;
  }
}

/* Items */
.img-item {
  position: relative;
  transform: translate(1, 1);
  -webkit-filter: grayscale(0%);
  filter: grayscale(0%);
  box-shadow: 0px 0px 0px rgba(0,0,0,0), 0 0px 0px rgba(0,0,0,0);
  transition: ease .5s;
  will-change: transform, box-shadow;
}

.item:hover .img-item {
  transform: translate(-2em, -2em);
  -webkit-filter: grayscale(75%);
  filter: grayscale(75%);
  box-shadow: 4px 10px 20px rgba(0,0,0,0.15), 0 6px 6px rgba(0,0,0,0.20);
  z-index: 1;
}

.thumb-title {
  position: absolute;
  bottom: 0;
  padding: .5em 1em;
  color: #ffffff;
  font-size: .8em;
  letter-spacing: .1em;
}

/* Footer */
footer {
  text-align: center;
}

.append-button {
  text-decoration: none;
  max-width: 100%;
  margin: 10px;
  padding: 12px 42px;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-transition: all 60ms ease-in-out;
  transition: all 60ms ease-in-out;
  text-align: center;
  text-decoration: none !important;
  text-transform: none;
  text-transform: capitalize;
  color: #fff;
  border: 0 none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  outline: none;
  color: #202129;
  background: #edeeee;
  opacity: 0;
  animation-name: button-show;
  animation-duration: 0.6s;
  animation-iteration-count: 1;
  animation-direction: alternate;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  animation-delay: 3s;
}

@keyframes button-show {
  0%  {
    opacity: 0;
  }
  100%  {
    opacity: 1
  }
}

.append-button:hover {
  -webkit-transition: all 60ms ease;
  transition: all 60ms ease;
  opacity: .85;
}

.append-button:hover {
  color: #202129;
  background-color: #e1e2e2;
  opacity: 1;
}

.status {
  display: none;
}

/* Lightbox */
.sandbox {
  display: none;
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: #000000;
  z-index: 100;
}

.lightbox {
  position: fixed;
  width: 94%;
  height: 94%;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  -o-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  background: black;
  background-size: contain;
  cursor: crosshair
}
              
            
!

JS

              
                /*
===============================================================

Hi! Welcome to my little playground!

My name is Tobias Bogliolo. 'Open source' by default and always 'responsive',
I'm a publicist, visual designer and frontend developer based in Barcelona. 

Here you will find some of my personal experiments. Sometimes usefull,
sometimes simply for fun. You are free to use them for whatever you want 
but I would appreciate an attribution from my work. I hope you enjoy it.

===============================================================
*/
//=====================
//=====================
//JSON Data:
//=====================
//=====================
var picsData = [
  {
    id: '1',
    title: 'Windows',
    description: 'Windows',
    alt: 'Windows',
    thumbName: '2-%20Arquitectura%2011_o.jpg',
    imgName: "2-%20Arquitectura%2011_o.jpg",
    classes: 'item item-mid',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '2',
    title: 'Over the Clouds',
    description: 'Over the Clouds',
    alt: 'Over the Clouds',
    thumbName: '1%20-%20Landscape%201.jpg',
    imgName: "1%20-%20Landscape%201_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '3',
    title: 'Paralyzed',
    description: 'Paralyzed',
    alt: 'Paralyzed',
    thumbName: '2012-8-3---Maria-y-Martina-en-Barcelon54a-8_out.jpg',
    imgName: "2012-8-3---Maria-y-Martina-en-Barcelon54a-8_out_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '4',
    title: 'The Guard',
    description: 'The Guard',
    alt: 'The Guard',
    thumbName: '4%20-%20Restratos%204_o.jpg', 
    imgName: "4%20-%20Restratos%204_o.jpg",
    classes: 'item item-mid',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '5',
    title: 'Human Being',
    description: 'Human Being',
    alt: 'Human Being',
    thumbName: '2012-10-29---Perrssssssssssssssssssssssssssssos_out_o.jpg', 
    imgName: "2012-10-29---Perrssssssssssssssssssssssssssssos_out_o.jpg",
    classes: 'item item-mid',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '6',
    title: 'Fire',
    description: 'Fire',
    alt: 'Fire',
    thumbName: 'ver-la-luz-24.jpg', 
    imgName: "ver-la-luz-24_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '7',
    title: 'Beyond the crowd',
    description: 'Beyond the crowd',
    alt: 'Beyond the crowd',
    thumbName: '5%20-%20Personas%207.jpg', 
    imgName: "5%20-%20Personas%207_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '8',
    title: 'Jamaa el Fna',
    description: 'Jamaa el Fna',
    alt: 'Jamaa el Fna',
    thumbName: '2009-7-21---Marrakech-2_o.jpg', 
    imgName: "2009-7-21---Marrakech-2_o.jpg",
    classes: 'item item-mid',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '9',
    title: 'Two Lovers',
    description: 'Two Lovers',
    alt: 'Two Lovers',
    thumbName: '5%20-%20Personas%2011.jpg', 
    imgName: "5%20-%20Personas%2011_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '10',
    title: 'Fringe',
    description: 'Fringe',
    alt: 'Fringe',
    thumbName: '2-%20Arquitectura%201_o.jpg', 
    imgName: "2-%20Arquitectura%201_o.jpg",
    classes: 'item item-big',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '11',
    title: 'Heads Elsewhere',
    description: 'Heads Elsewhere',
    alt: 'Heads Elsewhere',
    thumbName: '2-%20Arquitectura%2013_o.jpg', 
    imgName: "2-%20Arquitectura%2013_o.jpg",
    classes: 'item item-mid',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '12',
    title: 'Giraffes',
    description: 'Giraffes',
    alt: 'Giraffes',
    thumbName: '1%20-%20Landscape%208.jpg', 
    imgName: "1%20-%20Landscape%208_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '13',
    title: 'Alphabet',
    description: 'Alphabet',
    alt: 'Alphabet',
    thumbName: '2012-8-17---ABbfgfgC-3_out.jpg', 
    imgName: "2012-8-17---ABbfgfgC-3_out.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '14',
    title: 'Mirrors',
    description: 'Mirrors',
    alt: 'Mirrors',
    thumbName: '2-%20Arquitectura%206.jpg', 
    imgName: "2-%20Arquitectura%206_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '15',
    title: 'Columns',
    description: 'Columns',
    alt: 'Columns',
    thumbName: '3%20-%20Interiores%201_o.jpg', 
    imgName: "3%20-%20Interiores%201_o.jpg",
    classes: 'item item-mid',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '16',
    title: 'Advanced Gardening',
    description: 'Advanced Gardening',
    alt: 'Advanced Gardening',
    thumbName: '2011-9-12---Jardinero-2.jpg', 
    imgName: "2011-9-12---Jardinero-2_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '17',
    title: 'Grid',
    description: 'Grid',
    alt: 'Grid',
    thumbName: '2-%20Arquitectura%209.jpg', 
    imgName: "2-%20Arquitectura%209_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '18',
    title: 'Stone',
    description: 'Stone',
    alt: 'Stone',
    thumbName: 'Escultura%20-%202008-08-16-14_out_o.jpg', 
    imgName: "Escultura%20-%202008-08-16-14_out_o.jpg",
    classes: 'item item-mid',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '19',
    title: 'Light',
    description: 'Light',
    alt: 'Light',
    thumbName: '3%20-%20Interiores%208.jpg', 
    imgName: "3%20-%20Interiores%208_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '20',
    title: 'Scrabble',
    description: 'Scrabble',
    alt: 'Scrabble',
    thumbName: '2011-9-11---Tacheles-Scrabble---HUMANITY.jpg', 
    imgName: "2011-9-11---Tacheles-Scrabble---HUMANITY_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '21',
    title: 'X',
    description: 'X',
    alt: 'X',
    thumbName: 'IMG_0874_out_o.jpg', 
    imgName: "IMG_0874_out_o.jpg",
    classes: 'item item-mid',
    tags: ['photo', 'color', 'pattern', 'light']
  },
  {
    id: '22',
    title: 'Breathe',
    description: 'Breathe',
    alt: 'Breathe',
    thumbName: 'Escultura%20-%20IMG_1067_out.jpg', 
    imgName: "Escultura%20-%20IMG_1067_out_o.jpg",
    classes: 'item',
    tags: ['photo', 'color', 'pattern', 'light']
  }
];


//=====================
//=====================
//Script:
//=====================
//=====================
//Global vars:
var imgSrc = "http://payload100.cargocollective.com/1/9/296422/4317770/"; //Root directory.
var imgName;
var dataLength = picsData.length;
var loopLength = 3; //Set loop length.
var initItemsLength = 9; //set initial items length.
var itemDelay = 300; //Set delay between appended items.

//Create elements:
function getItem(param) {
  //Find data:
  var imgName = picsData[param].thumbName;
  //Create image:
  var image = new Image();
  image.className = 'img-item';
  image.src = imgSrc + imgName;
  //Create title:
  var title = document.createElement('span');
  title.className = "thumb-title";
  titleText = document.createTextNode(picsData[param].title);
  title.appendChild(titleText);
  //Create container:
  var item = document.createElement('div');
  item.className = picsData[param].classes;
  item.appendChild(title);
  item.appendChild(image);
  return item;
}

//Append initial items:
function appendItemInit(){
  for (i=0; i<initItemsLength; i++) {
    (function(i){
      setTimeout(function(){
        if (initItemsLength<dataLength) {
          //Get item:
          var elems = getItem(i);
          //Create jQuery object:
          var $elems = $(elems);
          //Append item:
          $(".grid").append($elems);
          // console.log(picsData[i].id);
        }
        else {
          $('.append-button').hide();
          $(".status").fadeIn();
        };
      }, itemDelay * i);
    }(i)); //Add delay between appended items.
  };
};
appendItemInit();

//Append new items:
function appendItem(){
  for (i=0; i<loopLength; i++) {
    (function(i){
      setTimeout(function(){
        if (initItemsLength<dataLength) {
          //Get item:
          var elems = getItem(initItemsLength);
          //Create jQuery object:
          var $elems = $(elems);
          //Append item:
          $(".grid").append($elems);
          // console.log(picsData[initItemsLength].id);
          //Modify items counter:
          initItemsLength += 1;
        }
        else {
          $('.append-button').hide();
          $(".status").fadeIn();
        };
      }, itemDelay * i);
    }(i)); //Add delay between appended items.
  };
};
$('.append-button').click(function() {
  appendItem();
});

//Infinite Scroll (trigger):
$(window).scroll(function() {
  if(Math.ceil($(window).scrollTop() + window.innerHeight) == $(document).height()) {
    appendItem();
  }
});

//Lightbox:
//Binding DOM after newly appended elements.
$(document).on('click', '.item', function() {
  //Find item into JSON:
  var thisItem = $(this).find(".img-item").attr("src");
  var n = thisItem.lastIndexOf('/');
  var result = thisItem.substring(n + 1);
  var index = picsData.map(function(e) { return e.thumbName; }).indexOf(result);
  console.log(index);
  //Lightbox display (fade in):
  $(".lightbox").css({
    "background": "url("+imgSrc+picsData[index].imgName+") no-repeat center",
    "background-size": "contain"
  });
  $(".sandbox").fadeIn(100);
  //Hide scrollbar
  $("html").css({"overflow-y": "hidden"});
});
//Lightbox display (fade out):
$(".sandbox").click(function(){
  $(".sandbox").fadeOut(100);
  //Show scrollbar:
  $("html").css({"overflow-y": "auto"});
});

              
            
!
999px

Console