Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <h1>Image Gallery</h1>
    
    <div class="container-fluid">
      <ul id="imageGallery">
        <li>
          <a href="https://i.imgur.com/BTRfA0D.png">
            <img src="https://i.imgur.com/BTRfA0D.png" alt="Boat by Griffin Moore">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/gSkOt7T.png">
            <img src="https://i.imgur.com/gSkOt7T.png" alt="Chuck by Mat Helme">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/B1JqazJ.png">
            <img src="https://i.imgur.com/B1JqazJ.png" alt="Wanted: Copy McRepeatsalot by Chris Michel">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/1e9rswE.png">
            <img src="https://i.imgur.com/1e9rswE.png" alt="Education by Chris Michel">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/NShslAl.png">
            <img src="https://i.imgur.com/NShslAl.png" alt="Illustrator Foundations by Matthew Spiel">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/6IfZsza.png">
            <img src="https://i.imgur.com/6IfZsza.png" alt="Library by Tyson Rosage">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/sfdvbFt.png">
            <img src="https://i.imgur.com/sfdvbFt.png" alt="Referal Machine by Matthew Spiel">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/f6cZZU9.png">
            <img src="https://i.imgur.com/f6cZZU9.png" alt="Sebastian by Mat Helme">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/WEbvIDZ.png">
            <img src="https://i.imgur.com/WEbvIDZ.png" alt="Skill Polish by Chris Michel">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/7roabAR.png">
            <img src="https://i.imgur.com/7roabAR.png" alt="Space Juice by Mat Helme">
          </a>
        </li>
        <li>
          <a href="https://i.imgur.com/HlNF7oY.jpg">
            <img src="https://i.imgur.com/HlNF7oY.jpg" alt="Treehouse Shop by Eric Smith">
          </a>
        </li>
      </ul>
    </div>
              
            
!

CSS

              
                body {
	color: white;
	font-family: sans-serif;
	background: #384047;
}

h1 {
	text-align: center;
	margin: 30px auto;
	font-weight: bold;
}

img {
	width: 120px;
	border: 10px solid white;
	margin: 10px;
}

ul {
	list-style: none;
}

li {
	display: inline-block;
}

.container-fluid {
	max-width: 800px;
	text-align: center;
}

#overlay {
	position: absolute;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, .7);
	top: 0;
	left: 0;
	display: none;
	text-align: center;
}

#overlay img {
	margin-top: 10%;
	width: 500px;
}
              
            
!

JS

              
                //store html elements into variables
var $overlay = $('<div id="overlay"></div>');
var $image = $("<img>");
var $caption = $("<p></p>");

//add the elements onto each other
$overlay.append($image);
$overlay.append($caption);
$("body").append($overlay);

//click event
$("#imageGallery a").click(function(event) {
	//prevent the default functionality of proceeding to a dead link
	event.preventDefault();
	//store the image location into a variable
	var imageLocation = $(this).attr("href");
	//set the image's attribute src to the image location
	$image.attr("src", imageLocation);
	//store the image's alt attribute text into a variable
	var captionText = $(this).children().attr("alt");
	//add the text into paragraph tags 
	$caption.text(captionText);
	//show the overlay
	$overlay.show();
});

//click event
$overlay.click(function() {
	//hide the overlay when clicked on
	$overlay.hide();
});
              
            
!
999px

Console