Skip to content

Instantly share code, notes, and snippets.

@samarkandiy
Created February 10, 2014 21:15
Show Gist options
  • Save samarkandiy/8924338 to your computer and use it in GitHub Desktop.
Save samarkandiy/8924338 to your computer and use it in GitHub Desktop.
A Pen by Avaz Bokiev.
<p>This is the main content. <a href="#" id="open">Open</a></p>
<div id="light" class="lightbox">
<img src="http://lorempixel.com/output/city-q-c-640-480-3.jpg" alt="" />
<a href="#" id="close">&#x2715;</a>
<span class="lightbox-caption">This is the image caption.</span>
</div>
<div id="fade" class="overlay"></div>
document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block';
document.getElementById('open').addEventListener('click', function() {
document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block';
});
document.getElementById('close').addEventListener('click', function() {
document.getElementById('light').style.display='none';
document.getElementById('fade').style.display='none';
});
.overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.lightbox{
display: none;
position: absolute;
top: 15%;
left: 25%;
width: 50%;
height: auto;
padding: 10px;
background: white;
z-index:1002;
}
#close{
background: #000;
color: #fff;
text-decoration: none;
width: 20px;
height: 20px;
line-height: 1.3;
text-align: center;
border: solid 2px #fff;
border-radius: 20px;
position: absolute;
padding: 3px;
right: -10px;
top: -10px;
}
.lightbox-caption{
background: #000;
color: #fff;
text-decoration: none;
width: 100%;
height: auto;
line-height: 1.3;
text-align: center;
border: solid 2px #fff;
border-radius: 20px;
position: absolute;
padding: 3px;
bottom: -40px;
left: -5px;
}
.lightbox img{
max-width: 100%;
min-width: 100%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment