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.

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

              
                <h2>fancybox v3.5 - Custom layout with  sidebar</h2>

<hr class="my-5" />

<div class="imglist">
  <a href="https://source.unsplash.com/Lzx4J_Pb3sk/1600x900" data-fancybox="images">
    <img src="https://source.unsplash.com/Lzx4J_Pb3sk/240x160" />
    <div class="caption">
      <p>Grasshopper lynx some much dear fish before beneath rattlesnake aside well but moth well more far the gosh meadowlark enviable apt jeepers locked alas.</p>
<p>Stylistic jay conic laughed dear less earthworm worm some groundhog far avowedly mastodon unobtrusive dogged obediently that ordered rancorous goodness far this alas until oh unkind.</p>
    </div>
  </a>

  <a href="https://source.unsplash.com/cZVthlrnlnQ/1600x900" data-fancybox="images">
    <img src="https://source.unsplash.com/cZVthlrnlnQ/240x160" />
    <div class="caption">
      <p>Rattlesnake gnu so regardless returned since abundant far more darn equivalently hound towards unthinking then emotional rode sensitive amongst erratically far unaccountably regardless and less or robin hippopotamus one.</p>
<p>Indubitably before but up and rampantly and irrespective that whispered outgrew iguanodon irrespective notwithstanding prior and from owing staunchly wow the modest much where the unanimously some where the or incredibly jeez morbid pill the.</p>
    </div>
  </a>

  <a href="https://source.unsplash.com/vddccTqwal8/1600x900" data-fancybox="images">
    <img src="https://source.unsplash.com/vddccTqwal8/240x160" />
    <div class="caption">
<p>A small river named Duden flows by their place and supplies it with the necessary regelialia.</p>
<p>It is a paradisematic country, in which roasted parts of sentences fly into your mouth.</p>
    </div>
  </a>

  <a href="https://source.unsplash.com/Sj5efgWguDs/1600x900" data-fancybox="images">
    <img src="https://source.unsplash.com/Sj5efgWguDs/240x160" />
    <div class="caption">
<p>Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.</p>
    </div>
  </a>
  
  <a href="https://source.unsplash.com/Y7y7fe8hrh0/1600x900" data-fancybox="images">
    <img src="https://source.unsplash.com/Y7y7fe8hrh0/240x160" />
    <div class="caption">
<p>Stylistic jay conic laughed dear less earthworm worm some groundhog far avowedly mastodon unobtrusive dogged obediently that ordered rancorous goodness far this alas until oh unkind.</p>
    </div>
  </a>
  
  <a href="https://source.unsplash.com/sYegwYtIqJg/1600x900" data-fancybox="images">
    <img src="https://source.unsplash.com/sYegwYtIqJg/240x160" />
    <div class="caption">
<p>Stylistic jay conic laughed dear less earthworm worm some groundhog far avowedly mastodon unobtrusive dogged obediently that ordered rancorous goodness far this alas until oh unkind.</p>
    </div>
  </a>

</div>

              
            
!

CSS

              
                /* Custom button design */
.fancybox-button {
  background: transparent;
  color: #333;
}

.fancybox-toolbar .fancybox-button:hover {
  background: rgba(223, 223, 223, 0.5);
  color: #c11c95;
}

/* Make close button a bit bigger */
.fancybox-button--close {
  padding: 7px;
}

/* Navigation arrows */
.fancybox-navigation .fancybox-button {
  z-index: 99996;
}

.fancybox-navigation .fancybox-button div {
  padding: 0;
}

.fancybox-navigation .fancybox-button[disabled],
.fancybox-navigation .fancybox-button[disabled]:hover {
  color: #888;
}

.fancybox-navigation .fancybox-button:hover {
  color: #000;
}

/* Change backdrop color */
.fancybox-bg {
  background: #eee;
}

/* Initially hide the caption */
.caption {
  display: none;
}

/* Change position and design of caption area */
.fancybox-caption {
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  padding: 0;
  width: 300px;
  background: #eee;
  color: #333;
  box-shadow: 0 0 20px #888;
  z-index: 99996;
  text-align: left;
  
  /* Hide next to right edge */
  transform: translate3d(320px, 0, 0);
}

.fancybox-caption::before {
  display: none;
}

.fancybox-caption > div {
  margin-top: 44px;
  padding: 20px;
  max-height: calc(100vh - 44px);
  overflow: auto;
}

/* Overwrite the default animation */
.fancybox-show-caption .fancybox-caption,
.fancybox-caption {
  transition: transform .2s;
}

/* Reveal caption */
 .fancybox-show-caption.fancybox-vertical-caption .fancybox-caption {
  transform: translate3d(0, 0, 0);
}

/* Styling of caption content */
.fancybox-caption a {
  color: #333;
}

.fancy-nav a {
  text-decoration: none;
  font-weight: normal;
  font-size: 20px;
  font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: #444;
  color: #fff;
  border-radius: 50%;
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 18px;
  text-align: center;
  -moz-user-select: none;
  user-select: none;
  cursor: pointer;
  outline: none;
}

.fancy-nav a:hover {
  text-decoration: none;
}
              
            
!

JS

              
                // Template for custom "info" button
$.fancybox.defaults.btnTpl.info = '<button data-fancybox-info class="fancybox-button fancybox-button--info" title="Show caption">&#x25cf;&#x25cf;&#x25cf;</button>';

// Initialise fancybox with custom settings
$('[data-fancybox="images"]').fancybox({
  preventCaptionOverlap : false,
  infobar: false,

  // Disable idle
  idleTime : 0,

  // Display only these two buttons
  buttons : [
    'info', 'close'
  ],

  // Custom caption content
  caption : function( instance, obj ) {
    return '<div><p class="fancy-nav"><a data-fancybox-prev title="Previous" tabindex="1">&lsaquo;</a> <a data-fancybox-next title="Next" tabindex="2">&rsaquo;</a> &nbsp; <span data-fancybox-index></span> of <span data-fancybox-count></span> images</p>' + $(this).find('.caption').html() + '</div>';
  },

  onInit: function(instance) {

    // Toggle caption on tap
    instance.$refs.container.on('touchstart', '[data-fancybox-info]', function(e) {
      e.stopPropagation();
      e.preventDefault();

      instance.$refs.container.toggleClass('fancybox-vertical-caption');
    });

    // Display caption on button hover
    instance.$refs.container.on('mouseenter', '[data-fancybox-info]', function(e) {
      instance.$refs.container.addClass('fancybox-vertical-caption');

      // Hide caption when mouse leaves caption area
      instance.$refs.caption.one('mouseleave', function(e) {
        instance.$refs.container.removeClass('fancybox-vertical-caption');
      });

    });

  }

});
              
            
!
999px

Console