JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://www.facticemagazine.com/css/scrolltotop/modernizr.js"></script>
<a class="lightbox" href=# rel="goofy">
<img src="https://static.makeuseof.com/wp-content/uploads/2016/04/photoshop-vs-gimp-670x335.jpg"/>
</a>
<div class="lightbox-target" id="goofy">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/158388/goofy.jpg"/>
<a class="lightbox-close" href="#"></a>
</div>
CSS
body, html {
padding: 0;
margin: 0;
text-align: center;
}
/* LIGHTBOX NEWS */
/* Styles the lightbox, removes it from sight and adds the fade-in transition */
a.lightbox img {
height: 150px;
border: 3px solid white;
box-shadow: 0px 0px 8px rgba(0,0,0,.3);
margin: 94px 20px 20px 20px;
}
.lightbox-target {
position: fixed;
top: -100%;
width: 100%;
background: rgba(40,40,40,.9);
width: 100%;
opacity: 0;
-webkit-transition: opacity .5s ease-in-out;
-moz-transition: opacity .5s ease-in-out;
-o-transition: opacity .5s ease-in-out;
transition: opacity .5s ease-in-out;
overflow: hidden;
z-index:999999999;
left: 0px;
}
/* Styles the lightbox image, centers it vertically and horizontally, adds the zoom-in transition and makes it responsive using a combination of margin and absolute positioning */
.lightbox-target img {
margin: auto;
position: absolute;
top: 0;
left:0;
right:0;
bottom: 0;
max-height: 0%;
max-width: 0%;
border: 0px solid white;
box-shadow: 0px 0px 8px rgba(0,0,0,0);
box-sizing: border-box;
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
padding:30px;
z-index:999999999;
}
/* Styles the close link, adds the slide down transition */
a.lightbox-close {
display: block;
width:50px;
height:50px;
box-sizing: border-box;
background: none;
color: white;
text-decoration: none;
position: absolute;
top: -80px;
right: 0;
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
}
/* Provides part of the "X" to eliminate an image from the close link */
a.lightbox-close:before {
content: "";
display: block;
height: 30px;
width: 1px;
background: white;
position: absolute;
left: 6px;
top:20px;
-webkit-transform:rotate(45deg);
-moz-transform:rotate(45deg);
-o-transform:rotate(45deg);
transform:rotate(45deg);
}
a.lightbox-close:after {
content: "";
display: block;
height: 30px;
width: 2px;
background:...
JavaScript
//OVERLAYS
$(document).ready(function() {
if (Modernizr.touch) {
// show the close overlay button
$(".close-overlay").removeClass("hidden");
// handle the adding of hover class when clicked
$(".effects .img").click(function(e) {
e.preventDefault();
e.stopPropagation();
if (!$(this).hasClass("hover")) {
$(this).addClass("hover");
}
});
// handle the closing of the overlay
$(".close-overlay").click(function(e) {
e.preventDefault();
e.stopPropagation();
});
} else {
// handle the mouseenter functionality
$(".effects .img").mouseenter(function() {
$(this).addClass("hover");
})
// handle the mouseleave functionality
.mouseleave(function() {
$(this).removeClass("hover");
});
}
});
// SMOOTH NAV SCROLL
$(function() {
$('a[href*=#])').click(function() {
if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 100);
return false;
}
}
});
});
// WAYPOINTS
$(function() {
$('.wp1').waypoint(function() {
$('.wp1').addClass('animated bounceInLeft');
}, {
offset: '85%'
});
$('.wp2').waypoint(function() {
$('.wp2').addClass('animated bounceInRight');
}, {
offset: '85%'
});
$('.wp3').waypoint(function() {
$('.wp3').addClass('animated bounceInLeft');
}, {
offset: '85%'
});
$('.wp4').waypoint(function() {
$('.wp4').addClass('animated fadeInUp');
}, {
offset: '85%'
});
$('.wp5').waypoint(function() {
$('.wp5').addClass('animated fadeInUp');
}, {
offset: '85%'
});
$('.wp6').waypoint(function() {
$('.wp6').addClass('animated fadeInUp');
}, {
offset: '85%'
});
});