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 + Slick carousel</h2>

<hr class="my-5" />


<p>
  These two demos show how to: 
</p>

<ol>
  <li>Solve a problem with cloned links</li>
  <li>Use multiple sliders</li>
  <li>Synchronize fancybox and slider (2nd demo)</li>
</ol>

<div class="main-slider my-5" style="max-width:900px;">
  <a href="https://via.placeholder.com/1200x800?text=1">
		<img src="https://via.placeholder.com/300x200?text=1" />
	</a>
	<a href="https://via.placeholder.com/1200x800?text=2">
		<img src="https://via.placeholder.com/300x200?text=2" />
	</a>
	<a href="https://via.placeholder.com/1200x800?text=3">
		<img src="https://via.placeholder.com/300x200?text=3" />
	</a>
  <a href="https://via.placeholder.com/1200x800?text=4">
		<img src="https://via.placeholder.com/300x200?text=4" />
	</a>
</div>

<div class="small-slider" style="background: #ddd;max-width:300px;">
	<a href="https://via.placeholder.com/1200x800?text=1">
		<img src="https://via.placeholder.com/300x200?text=1" />
	</a>
	<a href="https://via.placeholder.com/1200x800?text=2">
		<img src="https://via.placeholder.com/300x200?text=2" />
	</a>
	<a href="https://via.placeholder.com/1200x800?text=3">
		<img src="https://via.placeholder.com/300x200?text=3" />
	</a>
	<a href="https://via.placeholder.com/1200x800?text=4">
		<img src="https://via.placeholder.com/300x200?text=4" />
	</a>
</div>
  
              
            
!

CSS

              
                
              
            
!

JS

              
                // Open thumbs view straight away for demo purposes
$.fancybox.defaults.thumbs.autoStart = true;

// ============================
// Init 1st slider and fancybox
// ============================

// fancybox
$().fancybox({
  selector : '.main-slider .slick-slide:not(.slick-cloned)',
  backFocus : false
});

// Slick
$(".main-slider").slick({
  slidesToShow   : 3,
  infinite : true,
  dots     : false,
  arrows   : false
});

// ============================
// Init 2nd slider and fancybox
// ============================

// fancybox
$().fancybox({
  selector : '.small-slider .slick-slide:not(.slick-cloned)',
  backFocus : false,
  afterShow : function( instance, current ) {
    current.opts.$orig.closest(".slick-initialized").slick('slickGoTo', parseInt(current.index), true);
  }
});

// Slick
// =====

$(".small-slider").slick({
  slidesToShow   : 1,
  infinite : true,
  dots     : false,
  arrows   : false
});

// ================================================
// Attach custom click event on cloned elements, 
// trigger click event on corresponding link.
// Note: This will work for all sliders on the page
// ================================================
$(document).on('click', '.slick-cloned', function(e) {
  var $slides = $(this)
    .parent()
    .children('.slick-slide:not(.slick-cloned)');

  $slides
    .eq( ( $(this).attr("data-slick-index") || 0) % $slides.length )
    .trigger("click.fb-start", { $trigger: $(this) });

  return false;
});
              
            
!
999px

Console