Skip to content

Instantly share code, notes, and snippets.

@agusputra
Created November 6, 2015 07:44
Show Gist options
  • Select an option

  • Save agusputra/fea2ad619bb07140dc0b to your computer and use it in GitHub Desktop.

Select an option

Save agusputra/fea2ad619bb07140dc0b to your computer and use it in GitHub Desktop.
Simple lightbox example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.lightbox {
position: fixed;
/* Remove default browser outline */
outline: none;
z-index: 999;
width: 100%;
height: 100%;
text-align: center;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
}
.lightbox img {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
position: relative;
height: 95%;
width: auto;
top: 2.5%;
}
.lightbox button {
background: transparent;
border: transparent;
position: absolute;
top: 0;
right: 0.5em;
font-size: 3em;
color: white;
padding: 0;
}
</style>
</head>
<body>
<!-- lightbox container hidden with CSS -->
<div id="lightbox" class="lightbox">
<button type="button">&times;</button>
<img id="modalImage" src="http://placehold.it/512x1024" alt="">
</div>
<script src="https://code.jquery.com/jquery-git2.min.js"></script>
<script>
var lightbox = $("#lightbox").on("click", function () {
$(this).css("display", "none");
});
$("img", lightbox).on("click", function () {
return false;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment