Skip to content

Instantly share code, notes, and snippets.

@jameswestgate
Created April 11, 2012 09:11
Show Gist options
  • Save jameswestgate/2358178 to your computer and use it in GitHub Desktop.
Save jameswestgate/2358178 to your computer and use it in GitHub Desktop.
CSS Only Lightbox
#lightbox-overlay{
display: none;
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
background-color: black;
background-color: rgba(0,0,0,0.8);
z-index:9998;
}
#lightbox-content {
display:none;
position:static;
margin:100px auto;
width:480px;
height:600px;
padding:16px;
border:1px solid #ccc;
background-color:white;
z-index:9999;
overflow:none;
}
#lightbox-content iframe {
width:100%;
height:100%;
overflow:none;
}
<p><a href="#" onclick="showLightbox(); return false;">hello world<a></p>
<div id="lightbox-overlay" onclick="hideLightbox();">
<div id="lightbox-content">
<iframe src="http://news.bbc.co.uk"></iframe>
</div>
</div>
//May want to remove this at some stage
function showLightbox() {
document.getElementById('lightbox-overlay').style.display='block';
document.getElementById('lightbox-content').style.display='block';
}
function hideLightbox() {
document.getElementById('lightbox-overlay').style.display='none';
document.getElementById('lightbox-content').style.display='none';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment