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 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

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

              
                <div id="images">
	<ul id="image-wrapper">
		<li>
			<figure data-title="Image 1" data-desc="Lorem ipsum dolor sit amet.">
				<a href="#" class="image-link">
					<img src="http://lorempixel.com/400/200/abstract" alt=""/>
				</a>
			</figure>
			<figure data-title="Image 2" data-desc="Lorem ipsum dolor sit amet.">
				<a href="#" class="image-link">
					<img src="http://lorempixel.com/400/200/animals" alt=""/>
				</a>
			</figure>
			<figure data-title="Image 3" data-desc="Lorem ipsum dolor sit amet.">
				<a href="#" class="image-link">
					<img src="http://lorempixel.com/400/200/business" alt=""/>
				</a>
			</figure>
			<figure data-title="Image 4" data-desc="Lorem ipsum dolor sit amet.">
				<a href="#" class="image-link">
					<img src="http://lorempixel.com/400/200/city" alt=""/>
				</a>
			</figure>
			<div class="image-details">
				<a href="#" class="image-details-close">Close</a>
				<div class="image-details-content">
					<figure class="image"></figure>
				</div>
				<div class="image-details-desc">
					<h3 class="image-details-title"></h3>
					<p class="image-details-text"></p>
				</div>
			</div>
		</li>
		
		<li>
			<figure data-title="Image 5" data-desc="Lorem ipsum dolor sit amet.">
				<a href="#" class="image-link">
					<img src="http://lorempixel.com/400/200/food" alt=""/>
				</a>
			</figure>
			<figure data-title="Image 6" data-desc="Lorem ipsum dolor sit amet.">
				<a href="#" class="image-link">
					<img src="http://lorempixel.com/400/200/nightlife" alt=""/>
				</a>
			</figure>
			<figure data-title="Image 7" data-desc="Lorem ipsum dolor sit amet.">
				<a href="#" class="image-link">
					<img src="http://lorempixel.com/400/200/people" alt=""/>
				</a>
			</figure>
			<figure data-title="Image 8" data-desc="Lorem ipsum dolor sit amet.">
				<a href="#" class="image-link">
					<img src="http://lorempixel.com/400/200/technics" alt=""/>
				</a>
			</figure>
			<div class="image-details">
				<a href="#" class="image-details-close">Close</a>
				<div class="image-details-content">
					<figure class="image"></figure>
				</div>
				<div class="image-details-desc">
					<h3 class="image-details-title"></h3>
					<p class="image-details-text"></p>
				</div>
			</div>
		</li>

	</ul>
</div>

              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,400,700,300);

body {
	font: 300 14px/1.4 'Open Sans', sans-serif;
}

#images {
	margin: 2em auto;
	max-width: 800px;
}

#image-wrapper {
	margin: 0;
	padding: 0;
	list-style: none;
	overflow: hidden;
}

figure, figcaption, h3, p {
	margin: 0;
	padding: 0;
}

#image-wrapper li {
	overflow: hidden;
	display: block;
}

#image-wrapper li > figure {
	float: left;
	width: 25%;
	margin: 0;
}

#image-wrapper li > figure img {
	display: block;
	max-width: 100%;
	height: auto;
}

.image-details {
	clear: both;
	padding: 3em;
	background: #222;
	color: #fff;
	position: relative;
	overflow: hidden;
	display: none;
}

.image-details-close {
	position: absolute;
	top: 1em;
	right: 1em;
	width: 25px;
	height: 25px;
	text-indent: -9999em;
	background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2Fy ZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAA AAAAADw/eHBhY2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AVBJREFUeNrs29EOgiAUgOHoLeC5Mq17 3/+2DTeSOmvWFFSoYf5nO2tuTTwfYEKlnHOHPcfxsPMAAAAAAAAAAAAAAAAAAAAA AAAAAAAgJZRS/kX32fZp/PE30p9b2tByvD78nmDG1H3e3DNsn9fcPebPKed20pZO uebcAK17jy4nghTffbTRlgRgBr0zRLhkKP4yUryVNssACPRSEsJE8a/RVRRABKFZ UXwTKr5IgEiv1QuKr+eMpiIBUhHmFl80QGQInwPFn5dMoaIBAr1pxxCkeLtk1BQP EEGoBu+plha/GYBA7/rjk6SdM0o2CxBBWFX85gACQ31yavwdgFz0aQLhMSV+taDb /X4AU4CbIB+DPAjxKMxiiOUwGyJsibEpyrY4X4zw1Vime4CWXjFfXMAZaUOn3gMU f5jg9wEAAAAAAAAAAAAAAAAAAAD7i7sAAwB/21/1MhzmOwAAAABJRU5ErkJggg=='
);
background-size: 25px 25px;
background-repeat: no-repeat;
}

.image-details-content {
	float: left;
	width: 50%;
	margin: 0 3%;
	padding-right: 0.8em;
	border-right: 1px dotted #666;
}

.image {
	padding: 0.3em;
	border: 1px solid #888;
}

.image img {
	display: block;
	max-width: 100%;
	height: auto;
}

.image-details-desc {
	float: left;
	width: 40%;
	color: #767676;
}

.image-details-desc h3 {
	font-weight: normal;
	font-size: 19px;
	color: #fff;
	padding-bottom: 2px;
	border-bottom: 1px solid #777;
	margin-bottom: 0.3em;
}

              
            
!

JS

              
                (function( $ ) {
	$.imagePreview = function( element ) {
		this.$element = $( element );
		this.init();
	};
	
	$.imagePreview.prototype = {
		init: function() {
			this.$triggers = this.$element.find( ".image-link" );
			this.$closeLinks = this.$element.find( ".image-details-close" );
			
			this.open();
			this.close();
		},
		
		_getContent: function( element ) {
			var $parent = element.parent(),
				title = $parent.data( "title" ),
				desc = $parent.data( "desc" ),
				html = element.html();
				
				return {
					title: title,
					desc: desc,
					html: html
				}
		},
		
		open: function() {
			var self = this;
			self.$triggers.on( "click", function( e ) {
				e.preventDefault();
				var $a = $( this ),
					content = self._getContent( $a ),
					$li = $a.parents( "li" ),
					$details = $( ".image-details", $li ),
					$contentImage = $( ".image", $details ),
					$detailsTitle = $( ".image-details-title", $details ),
					$detailsText = $( ".image-details-text", $details );
					
					$contentImage.html( content.html );
					$detailsTitle.text( content.title );
					$detailsText.text( content.desc );
					
					self.$element.find( ".image-details" ).slideUp( "fast" );
					$details.slideDown( "fast" );
				
			});
		},
		close: function() {
			this.$closeLinks.on( "click", function( e ) {
				e.preventDefault();
				$( this ).parent().slideUp( "fast" );
				
			});
		}	
	};
	
	$(function() {
		var preview = new $.imagePreview( "#image-wrapper" );
		
	});
	
})( jQuery );

              
            
!
999px

Console