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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div class="container">

  <!-- Gallery -->
  <div id="js-gallery" class="gallery">

    <!--Gallery Hero-->
    <div class="gallery__hero">
      <a href="" class="gallery__hero-enlarge ir" data-gallery="zoom">Zoom</a>

      <img src="https://public-619e3.firebaseapp.com/Product-Gallery/products/normal/product-01_view-01.jpg">
    </div>
    <!--Gallery Hero-->

    <!--Gallery Thumbs-->
    <div class="gallery__thumbs">
        <a href="https://public-619e3.firebaseapp.com/Product-Gallery/products/normal/product-01_view-01.jpg" data-gallery="thumb" class="is-active">
          <img src="https://public-619e3.firebaseapp.com/Product-Gallery/products/thumb/product-01_view-01.jpg">
        </a>
        <a href="https://public-619e3.firebaseapp.com/Product-Gallery/products/normal/product-01_view-02.jpg" data-gallery="thumb">
          <img src="https://public-619e3.firebaseapp.com/Product-Gallery/products/thumb/product-01_view-02.jpg">
        </a>
        <a href="https://public-619e3.firebaseapp.com/Product-Gallery/products/normal/product-01_view-03.jpg" data-gallery="thumb">
          <img src="https://public-619e3.firebaseapp.com/Product-Gallery/products/thumb/product-01_view-03.jpg">
        </a>
    </div>
    <!--Gallery Thumbs-->

  </div><!--.gallery-->
  <!-- Gallery -->
  
 </div><!--.container-->
              
            
!

CSS

              
                /**
 * Variables
 */

// Spacing
$base-spacing: 1em;

// Colors
$off-white: #F5F5F5;
$base-accent-color: #34Bf49;

// Thumb Opacity Settings
$thumb-opacity-inactive: 0.75;
$thumb-opacity-hover: 1;
$thumb-opacity-active: 0.2;

// Icon Opacity Settings
$icon-opacity-norm: 0.5;
$icon-opacity-hover: 1;

// Transition Settings
$base-transition-timing: cubic-bezier(0.455,  0.030, 0.515, 0.955);
$base-transition-duration: .3s;


/**
 * Base Styles
 * 1. Improve box model
 * 2. Enable fluid images
 */

*,
*:before,
*:after {
  box-sizing: border-box; /* 1 */
}

body {
  background-color: $off-white;
}

img {
  max-width: 100%; /* 2 */
}


/**
 * Container Styles
 */

.container {
  max-width: 30em;
  margin: 0 auto;
  padding: 1em;
}


/**
 * Helper Styles
 */

// Image Replacement
.ir {
  text-indent: 100%;
  white-space: nowrap;
  overflow: hidden;
}


/**
 * Gallery Styles
 * 1. Enable fluid images
 */

.gallery {
  overflow: hidden;
}

.gallery__hero {
	overflow: hidden;
	position: relative;
  padding: $base-spacing*2;
  margin: 0 0 $base-spacing/3;
	background: #fff;

	// Modifiers
	.is-zoomed & {
    cursor: move;
		img {
			max-width: none;
			position: absolute;
			z-index: 0;
			top: -50%;
			left: -50%;
		}
	}
}

.gallery__hero-enlarge {
  position: absolute;
  right: $base-spacing/2;
  bottom: $base-spacing/2;
	z-index: 1;
  width: 30px;
  height: 30px;
  opacity: $icon-opacity-norm;
  background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMCIgaGVpZ2h0PSIzMCIgdmlld0JveD0iNS4wIC0xMC4wIDEwMC4wIDEzNS4wIiBmaWxsPSIjMzRCZjQ5Ij48cGF0aCBkPSJNOTMuNT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eat;
  transition: opacity $base-transition-duration $base-transition-timing;
  
  &:hover {
    opacity: $icon-opacity-hover;
  }
  
  // Modifiers
  .is-zoomed & {
    background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMCIgaGVpZ2h0PSIzMCIgdmlld0JveD0iNS4wIC0xMC4wIDEwMC4wIDEzNS4wIiBmaWxsPSIjMzRCZjQ5Ij48cGF0aCBkPSJNOTMuNTkzIDg2LjgxNkw3Ny4wNDUgNzAuMjY4YzUuNDEzLTYuODczIDguNjQyLTE1LjUyNiA4LjY0Mi0yNC45MTRDODUuNjg3IDIzLjEwNCA2Ny41OTMgNSA0NS4zNDMgNVM1IDIzLjEwNCA1IDQ1LjM1NGMwIDIyLjI0IDE4LjA5NCA0MC4zNDMgNDAuMzQzIDQwLjM0MyA5LjQgMCAxOC4wNjItMy4yNCAyNC45MjQtOC42NTNsMTYuNTUgMTYuNTZjLjkzNy45MjcgMi4xNjIgMS4zOTYgMy4zODggMS4zOTYgMS4yMjUgMCAyLjQ1LS40NyAzLjM5LTEuMzk2IDEuODc0LTEuODc1IDEuODc0LTQuOTEyLS4wMDItNi43ODh6TTE0LjU5IDQ1LjM1NGMwLTE2Ljk2NCAxMy44LTMwLjc2NCAzMC43NTMtMzAuNzY0IDE2Ljk2NCAwIDMwLjc1MyAxMy44IDMwLjc1MyAzMC43NjQgMCAxNi45NTQtMTMuNzkgMzAuNzUzLTMwLjc1MyAzMC43NTMtMTYuOTUzIDAtMzAuNzUzLTEzLjgtMzAuNzUzLTMwLjc1M3pNNTguNzcyIDQ5LjYxSDMxLjkyYy0yLjM1NSAwLTQuMjYzLTEuOTA3LTQuMjYzLTQuMjZzMS45MDgtNC4yNjMgNC4yNjItNC4yNjNINTguNzdjMi4zNTQgMCA0LjI2MiAxLjkwOCA0LjI2MiA0LjI2MnMtMS45MSA0LjI2LTQuMjYyIDQuMjZ6Ii8+PC9zdmc+); 
  }
}

.gallery__thumbs {
  text-align: center;
  background: #fff;
	a {
    display: inline-block;
		width: 20%;
    padding: $base-spacing/2;
    opacity: $thumb-opacity-inactive;
    transition: opacity $base-transition-duration $base-transition-timing;
    
    &:hover {
      opacity: $thumb-opacity-hover;
    }
    
    // Modifiers
    &.is-active {
      opacity: $thumb-opacity-active;
    }
	}
}
              
            
!

JS

              
                var App = (function () {

  //=== Use Strict ===//
  'use strict';

  //=== Private Variables ===//
  var gallery = $('#js-gallery');

  //=== Gallery Object ===//
  var Gallery = {
    zoom: function(imgContainer, img) {
      var containerHeight = imgContainer.outerHeight(),
      src = img.attr('src');
      
      if ( src.indexOf('/products/normal/') != -1 ) {
        // Set height of container
        imgContainer.css( "height", containerHeight );
        
        // Switch hero image src with large version
        img.attr('src', src.replace('/products/normal/', '/products/zoom/') );
        
        // Add zoomed class to gallery container
        gallery.addClass('is-zoomed');
        
        // Enable image to be draggable
        img.draggable({
          drag: function( event, ui ) {
            ui.position.left = Math.min( 100, ui.position.left );
            ui.position.top = Math.min( 100, ui.position.top );
          }
        });
      } else {
        // Ensure height of container fits image
        imgContainer.css( "height", "auto" );
        
        // Switch hero image src with normal version
        img.attr('src', src.replace('/products/zoom/', '/products/normal/') );
        
        // Remove zoomed class to gallery container
        gallery.removeClass('is-zoomed');
      }
    },
    switch: function(trigger, imgContainer) {
      var src = trigger.attr('href'),
      thumbs = trigger.siblings(),
			img = trigger.parent().prev().children();
      
      // Add active class to thumb
      trigger.addClass('is-active');
      
      // Remove active class from thumbs
      thumbs.each(function() {
        if( $(this).hasClass('is-active') ) {
          $(this).removeClass('is-active');
        }
      });

      // Reset container if in zoom state
      if ( gallery.hasClass('is-zoomed') ) {
        gallery.removeClass('is-zoomed');
        imgContainer.css( "height", "auto" );
      }

      // Switch image source
      img.attr('src', src);
    }
  };

  //=== Public Methods ===//
  function init() {

    // Listen for clicks on anchors within gallery
    gallery.delegate('a', 'click', function(event) {
      var trigger = $(this);
      var triggerData = trigger.data("gallery");

      if ( triggerData === 'zoom') {
        var imgContainer = trigger.parent(),
        img = trigger.siblings();
        Gallery.zoom(imgContainer, img);
      } else if ( triggerData === 'thumb') {
        var imgContainer = trigger.parent().siblings();
        Gallery.switch(trigger, imgContainer);
      } else {
        return;
      }

      event.preventDefault();
    });

  }

  //=== Make Methods Public ===//
  return {
    init: init
  };

})();

App.init();
              
            
!
999px

Console