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>Example of <a href="http://fancyapps.com/fancybox/3/">FancyBox</a> lightbox</h2>

<div class="gallery">
	<a href="https://home.ctw.utwente.nl/slootenvanf/div/fancybox_images/Chrysanthemum.jpg"><img src="https://home.ctw.utwente.nl/slootenvanf/div/fancybox_images/tn/Chrysanthemum.jpg" alt="Chrysanthemum: nice flower."></a>
	<a href="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/Desert.jpg"><img src="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/tn/Desert.jpg" alt="Desert mountains"></a>
	<a href="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/Hydrangeas.jpg"><img src="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/tn/Hydrangeas.jpg" width="100" height="75" alt="Hydrangeas, called 'Hortensia' in Dutch"></a>
	<a href="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/Jellyfish.jpg"><img src="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/tn/Jellyfish.jpg" title="Jellyfish"></a>
	<a href="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/Koala.jpg"><img src="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/tn/Koala.jpg" alt="Koala"></a>
	<a href="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/Lighthouse.jpg"><img src="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/tn/Lighthouse.jpg" alt="Lighthouse"></a>
	<a href="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/Penguins.jpg"><img src="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/tn/Penguins.jpg" alt="Penguins"></a>
	<a href="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/Tulips.jpg"><img src="https://home.et.utwente.nl/slootenvanf/div/fancybox_images/tn/Tulips.jpg" alt="Yellow tulips"></a>
</div>

<div class="block">
Steps to create a webpage with this viewer:
<ol>
<li>Add jQuery and FancyBox scripts to the header of your webpage:
<pre>
&lt;!-- Below we include the jQuery Library --&gt;
&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"&gt;&lt;/script&gt;

&lt;!-- Add fancyBox --&gt;
&lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" type="text/css" media="screen" /&gt;
&lt;script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"&gt;&lt;/script&gt;</pre>

</li>
  <li><p>Create a set of linked images:</p>
<pre>
&lt;div class="gallery"&gt;
&lt;a href="fullsize.png"&gt;&lt;img src="thumbnail.png"&gt;&lt;/a&gt;
&lt;a href="fullsize.png"&gt;&lt;img src="thumbnail.png"&gt;&lt;/a&gt;
&lt;a href="fullsize.png"&gt;&lt;img src="thumbnail.png"&gt;&lt;/a&gt;
...
&lt;/div&gt;
</pre>
  <p>For better performance, use thumbnails in the <code>img src</code>.</p>
</li>
  
  <li><p>At the end of the page, add the script to start FancyBox:</p>
<pre>
&lt;script&gt;
$(document).ready(function() {
  $(".gallery a").fancybox();
});
&lt;/script&gt;
</pre>
</li>
</ol>
<p>Detailed instructions, options, examples and tips & tricks can be found on the
  <a href="http://fancyapps.com/fancybox/3/">FancyBox site</a>.</p>
</div>

              
            
!

CSS

              
                body {
	font: 15px Arial, Sans-serif;
}

.gallery {
	display: inline-block;
	text-align: center;
	margin: 10px auto;
	clear: both;
	padding: 0;
	padding: 10px;
	background-color: #ccc;
	border-radius: 5px;
}

.gallery img { /* thumbnails */
	width: 100px;
  height: 75px;
}

.block {
	display: inline-block;
	background-color: #ccc;
	border-radius: 5px;
	padding: 8px;
}

pre {
  background-color: #eee;
	border-radius: 5px;
	padding: 8px;
	clear: both;
}

.highlight {
	color: red;
}

              
            
!

JS

              
                $(document).ready(function() {
  // add all to same gallery
  $(".gallery a").attr("data-fancybox","mygallery");
  // assign captions and title from alt-attributes of images:
  $(".gallery a").each(function(){
    $(this).attr("data-caption", $(this).find("img").attr("alt"));
    $(this).attr("title", $(this).find("img").attr("alt"));
  });
  // start fancybox:
	$(".gallery a").fancybox();
});

              
            
!
999px

Console