cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <!-- Lightbox usage markup -->
<link href="https://fonts.googleapis.com/css?family=Raleway:200,100,400" rel="stylesheet" type="text/css" />
<h1>Mostly CSS Lightbox</h1>
<p>Supports images, youtube, and vimeo content.</p>
<p> While this uses only HTML and CSS for the layout, layering, and animation, it <i>does</i> require Javascript to allow for automated video play/pause when opening/closing the lightbox layer. Otherwise videos won't play when opened, and will keep playing when invisible, and we don't want that, now, do we!</p>
<p>YouTube and Vimeo API scripts are loaded in the header, while the iframes include onload actions to initialise the APIs, and the anchor elements include onclick actions for setting status. It's about as simple as it can get, but does require CMS support to make manageable.</p>
<p>The primary change between versions 2 and 3 is the addition of previous/next button placeholders, along with separating the anchor tags from the container (which is now a div).</p>

<!-- thumbnail images wrapped in a link -->
<a class="thumbnail" href="#img1"><img src="http://placehold.it/240x101" /></a>
<a class="thumbnail" href="#img2"><img src="http://placehold.it/240x102" /></a>
<a class="thumbnail" href="#img3"><img src="http://placehold.it/240x103" /></a>
<!-- lightbox containers hidden with CSS -->
<div class="lightbox animate" id="img1"><a class="lightboxClose" href="#!">close</a><a class="lightboxPrev" href="#img3">previous</a><a class="lightboxNext" href="#img2">next</a><img class="animate" src="http://placehold.it/960x501" /></div>
</div>
<div class="lightbox animate" id="img2"><a class="lightboxClose" href="#!">close</a><a class="lightboxPrev" href="#img1">previous</a><a class="lightboxNext" href="#img3">next</a><img class="animate" src="http://placehold.it/960x502" /></div>
</div>
<div class="lightbox animate" id="img3"><a class="lightboxClose" href="#!">close</a><a class="lightboxPrev" href="#img2">previous</a><a class="lightboxNext" href="#img1">next</a><img class="animate" src="http://placehold.it/960x503" /></div>
</div>

</br></br></br>

<!-- thumbnail image wrapped in a link -->
<a class="thumbnail" href="#vid1" onclick="vid1.playVideo()"><img src="http://placehold.it/240x135" /></br>youtube</a>
<!-- lightbox container hidden with CSS -->
<div class="lightbox animate" id="vid1"><a class="lightboxClose" href="#!" onclick="vid1.pauseVideo()">close</a><iframe class="animate" width="960" height="510" src="https://www.youtube.com/embed/ZVkT-kunlWw?enablejsapi=1" frameborder="0" allowfullscreen onload="vid1=new YT.Player(this)"></iframe></div>

</br></br></br>

<!-- thumbnail image wrapped in a link -->
<a class="thumbnail" href="#vid2" onclick="vid2.play()"><img src="http://placehold.it/240x135" /></br>vimeo</a>
<!-- lightbox container hidden with CSS -->
<div class="lightbox animate" id="vid2"><a class="lightboxClose" href="#!" onclick="vid2.pause()">close</a><iframe class="animate"src="https://player.vimeo.com/video/146707828" width="960" height="540" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen onload="vid2=new Vimeo.Player(this)"></iframe></div>

</br></br></br>

<h3>Known bugs:</h3>
<p>The YouTube API will not automatically restart a finished video until the second "play" commend. This means watching a video, letting it finish, then closing and re-opening the lightbox will not autoplay from the begining, but trying a second time will.</p>
<p>The Vimeo API will sometimes start playing again after receiving a pause command if a user tries to open another lightbox layer too quickly. This means a video may play while invisible, and can only be stopped by opening the layer and closing again. I thought it might be because the pause command was bi-directional (pause/unpause), but that doesn't seem to be the case (testing for play status before pausing doesn't fix it, and of course pausing before closing doesn't restart playing either).</p>

<!--
<iframe width="960" height="540" src="https://www.youtube.com/embed/ZVkT-kunlWw" frameborder="0" allowfullscreen></iframe>
-->
            
          
!
            
              /*Eliminates padding, sets up document style */

body, html {
	padding: 0;
	margin: 0;
	text-align: center;
	font-family: 'Raleway', sans-serif;
	font-size: 18px;
	color: #888480;
	background-color: #202428;
}

p {
	width: 40%;
	min-width: 420px;
	max-width: 800px;
	margin: 30px auto;
	line-height: 1.3em;
}

a {
	color: #fff;
	text-decoration: none;
}

/* Styles the thumbnail */

a.thumbnail img {
	margin: 20px;
	border: 2px solid white;
	border-radius: 10px;
}

/* Removes browser highlight outlines for all links */

a {
	outline: none;
}

/* Styles the lightbox, removes it from sight and adds the fade-in transition */

.lightbox {
	display: block;
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	background: rgba(0, 0, 0, .5);
	visibility: hidden;
	opacity: 0;
}

.lightboxClose {
	display: block;
	position: absolute;
	width: 100%;
	height: 100%;
}

.lightboxPrev {
	display: block;
	position: absolute;
	left: 0px;
	top: 30%;
	width: 10%;
	height: 40%;
	background-color: rgba(255, 255, 255, 0.1);
}

.lightboxNext {
	display: block;
	position: absolute;
	right: 0px;
	top: 30%;
	width: 10%;
	height: 40%;
	background-color: rgba(255, 255, 255, 0.1);
}

.animate {
	-webkit-transition: .25s ease-in-out;
	-moz-transition: .25s ease-in-out;
	-ms-transition: .25s ease-in-out;
	-o-transition: .25s ease-in-out;
	transition: .25s ease-in-out;
}

/* Styles the lightbox content, centering it vertically and horizontally, adds the zoom-in transition and makes it responsive using a combination of margin and absolute positioning */

.lightbox img, .lightbox iframe {
	margin: auto;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	max-width: 40%;
	max-height: 40%;
	border: 2px solid white;
	box-sizing: border-box;
}

/* Uses the :target pseudo-class to perform the animations upon clicking the .lightbox anchor */

.lightbox:target {
	visibility: visible;
	opacity: 1;
}

.lightbox:target img, .lightbox:target iframe {
	max-width: 95%;
	max-height: 95%;
}

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console