cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <h1>Image Gallery</h1>
<div class="intro">
  <p>
    Galleries are tricky, specially when every image is a different size.
    Here's an example of how I deal with the issue, make them all square!
  </p>
</div>

<div class="image-gallery">
  <div class="image-gallery-items">
    <div class="gallery-item">
      <div>
        <a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/1---ZWhG9Fz.jpg" class="thumbnail">
          <span>
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/1---ZWhG9Fz-th.jpg" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/2---JUcW6Fi.jpg" class="thumbnail">
          <span>
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/2---JUcW6Fi-th.jpg" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/6xjvs6j.jpg" class="thumbnail">
          <span>
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/6xjvs6j-th.jpg" alt="" />
          </span>
        </a>
      </div>
    </div>

    <div class="gallery-item">
      <div>
        <a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/7FCc1Aw.jpg" class="thumbnail">
          <span>
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/7FCc1Aw-th.jpg" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/7tABmGl.jpg" class="thumbnail">
          <span>
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/7tABmGl-th.jpg" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/8n6nkkq.jpg" class="thumbnail">
          <span>
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/8n6nkkq-th.jpg" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/93pP3VW.jpg" class="thumbnail">
          <span>
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/93pP3VW-th.jpg" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/A7BmIzU.jpg" class="thumbnail">
          <span>
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19554/A7BmIzU-th.jpg" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="http://placehold.it/800x600" class="thumbnail">
          <span>
            <img src="http://placehold.it/300x200" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="http://placehold.it/800x600" class="thumbnail">
          <span>
            <img src="http://placehold.it/300x200" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="http://placehold.it/800x600" class="thumbnail">
          <span>
            <img src="http://placehold.it/300x200" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="http://placehold.it/800x600" class="thumbnail">
          <span>
            <img src="http://placehold.it/300x210" alt="" />
          </span>
        </a>
      </div>
    </div>
    <div class="gallery-item">
      <div>
        <a href="http://placehold.it/800x600" class="thumbnail">
          <span>
            <img src="http://placehold.it/298x200" alt="" />
          </span>
        </a>
      </div>
    </div>
  </div>
</div>
            
          
!
            
              // Creates a keyframe to use with animations
@mixin keyframes($animationName) {
  @-webkit-keyframes #{$animationName} {
    @content;
  }
  @-moz-keyframes #{$animationName} {
    @content;
  }
  @-o-keyframes #{$animationName} {
    @content;
  }
  @keyframes #{$animationName} {
    @content;
  }
}

// Prefixes properties with browser specific tags
@mixin prefix($declarations, $prefixes: webkit moz) {
  @each $property,
  $value in $declarations {
    @each $prefix in $prefixes {
      #{'-' + $prefix + '-' + $property}: $value;
    }
    // Output standard non-prefixed declaration
    #{$property}: $value;
  }
}

// clearfix hack
@mixin clearfix {
  &:before,
  &:after {
    content: " ";
    display: table;
  }
  &:after {
    clear: both;
  }
}

// Centers an element using the absolute positioning hack
@mixin absolute-center {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

@mixin scrollbars($size, $foreground-color, $background-color: mix($foreground-color, white,  50%)) {
  // For Google Chrome
  ::-webkit-scrollbar {
      width:  $size;
      height: $size;
  }

  ::-webkit-scrollbar-thumb {
      background: $foreground-color;
  }

  ::-webkit-scrollbar-track {
      background: $background-color;
  }
}

////////////////////////////////////////////////////////////
@include keyframes(animate-body) {
  0% { background-position: 0% 50% }
  50% { background-position: 100% 50% }
  100% { background-position: 0% 50% }
}

*, *:before, *:after {
  @include prefix((box-sizing: border-box));
}

@include scrollbars(.5em, #888, #ddd);

body {
  background: linear-gradient(328deg, #ff5252, #ff71a8);
  background-size: 600% 600%;
  font-family: 'Overlock', cursive;
  font-size: 100%;
  @include prefix((animation: animate-body 30s ease infinite));
}

//---------------------
// # Intro
//---------------------
h1 {
  font-family: 'Comfortaa', cursive;
  font-size: 2.55em;
  text-align: center;
  color: #fff;
  text-shadow: 0 3px 10px #ec3f3f;
}

.intro {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  
  p {
    color: #fff;
    font-size: 1.145em;
    
    @media screen and (max-width: 600px) {
      padding-left: 8px;
      padding-right: 8px;
    }
  }
}

//---------------------
// # Gallery Items
//---------------------
.image-gallery {
  width: 100%;
  height: auto;
  max-width: 700px;
  background: #fff;
  overflow: auto;
  padding: 5px;
  margin: 50px auto 0;
  @include prefix(( box-shadow: 0 3px 10px #ec3f3f));
  
  @media screen and (min-width: 800px) {
    height: 500px;
  }
  
  &-items {
    position: relative;
    @include clearfix;
  }
}

.gallery-item {
  position: relative;
  float: left;
  width: 50%;
  padding: 8px;
  margin: 0;
  cursor: pointer;
  text-align: center;
  
  @media screen and (min-width: 480px) {
    width: 33.33333%;
  }
  
  @media screen and (min-width: 680px) {
    width: 25%;
  }
  
  @include prefix((user-select: none));
  > div {
    position: relative;
    &:before {
      content: "";
      display: block;
      padding-top: 100%;
    }
  }
}

.thumbnail {
  overflow: hidden;
  @include absolute-center;
  &:after {
    content: "";
    display: block;
    overflow: hidden;
    @include absolute-center;
  }
  img {
    position: absolute;
    top: 0;
    left: 0;
    max-height: 100%;
    max-width: inherit;
    @include prefix(( transform: translate(-50%, -50%), transition: transform 150ms ease-in-out));
  }
  span {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    @include prefix(( transform: translate(50%, 50%)));
  }
  &:hover img {
    @include prefix((transform: translate(-50%, -50%) scale(1.15)));
  }
}

//---------------------
// # Popup
//---------------------

.mfp {
  &-bg {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1042;
    overflow: hidden;
    position: fixed;
    background: #0b0b0b;
    opacity: 0.8;
  }
  &-wrap {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1043;
    position: fixed;
    outline: none !important;
    @include prefix((backface-visibility: hidden));
  }

  &-container {
    text-align: center;
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    padding: 0 8px;
    box-sizing: border-box;
    
    &:before {
      content: '';
      display: inline-block;
      height: 100%;
      vertical-align: middle;
    }
  }

  &-content {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    margin: 0 auto;
    text-align: left;
    z-index: 1045;
  }

  &-inline-holder &-content,
  &-ajax-holder &-content{
    width: 100%;
    cursor: auto;
  }

  &-hide { display: none !important; }

  &-close {
    width: 44px;
    height: 44px;
    line-height: 44px;
    position: absolute;
    right: 0;
    top: 0;
    text-decoration: none;
    text-align: center;
    opacity: 0.65;
    padding: 0 0 18px 10px;
    color: #fff;
    background: none;
    border: none;
    font-style: normal;
    font-size: 28px;
    font-family: Arial, Baskerville, monospace;

    &:hover,
    &:focus {
      opacity: 1;
      cursor: pointer;
      outline: 0;
    }
    &:active {
      top: 1px;
    }
  }

  &-image-holder &-close {
    color: #fff;
    right: -6px;
    text-align: right;
    padding-right: 6px;
    width: 100%;
  }

  &-image-holder &-content {
    max-width: 100%;
  }

  &-img {
    width: auto;
    max-width: 100%;
    height: auto;
    display: block;
    line-height: 0;
    box-sizing: border-box;
    padding: 40px 0;
    margin: 0 auto;
  }

  &-figure {
    line-height: 0;
    cursor: pointer;

    &:after {
      content: '';
      position: absolute;
      left: 0;
      top: 40px;
      bottom: 40px;
      display: block;
      right: 0;
      width: auto;
      height: auto;
      z-index: -1;
      box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
      background: #444;
    }
    small {
      color: #bdbdbd;
      display: block;
      font-size: 12px;
      line-height: 14px;
    }
    figure {
      margin: 0;
    }
  }

  &-bottom-bar {
    margin-top: -40px + 4;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    cursor: auto;
  }

  &-title {
    text-align: left;
    line-height: 18px;
    color: #f3f3f3;
    word-wrap: break-word;
    padding-right: 36px;
  }

  &-counter {
    position: absolute;
    top: 0;
    right: 0;
    color: #f3f3f3;
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
  }

  &-arrow {
    position: absolute;
    opacity: 0.65;
    margin: 0;
    top: 50%;
    margin-top: -55px;
    padding: 0;
    width: 90px;
    height: 110px;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    background: none;
    border: none;
    cursor: pointer;
    
    &:active {
      margin-top: -54px;
    }
    &:hover,
    &:focus {
      opacity: 1;
    }
    &:before,
    &:after {
      content: '';
      display: block;
      width: 0;
      height: 0;
      position: absolute;
      left: 0;
      top: 0;
      margin-top: 35px;
      margin-left: 35px;
      border: medium inset transparent;
    }
    &:after {
      border-top-width: 13px;
      border-bottom-width: 13px;
      top: 8px;
    }
    &:before {
      border-top-width: 21px;
      border-bottom-width: 21px;
      opacity: 0.7;
    }
  }

  &-arrow-left {
    left: 0;
    &:after {
      border-right: 17px solid #fff;
      margin-left: 31px;
    }
    &:before {
      margin-left: 25px;
      border-right: 27px solid #3f3f3f;
    }
  }

  &-arrow-right {
    right: 0;
    &:after {
      border-left: 17px solid #fff;
      margin-left: 39px
    }
    &:before {
      border-left: 27px solid #3f3f3f;
    }
  }

  &-s-ready &-preloader { display: none !important }
}
            
          
!
            
              (function($) {
  $('a.thumbnail').magnificPopup({
    type: 'image',
    closeOnContentClick: true,
    closeBtnInside: false,
    gallery: { enabled: true },
    fixedContentPos: true,
    mainClass: 'mfp-no-margins mfp-with-zoom',
    image: {
      verticalFit: true
    },
    zoom: {
      enabled: true,
      duration: 300
    }
  });
})(jQuery);
            
          
!
999px
Loading ..................

Console