JSFiddle - React, Tailwind, and code Playground

by KURO KUMO

HTML

<div id="boxes">
<div style="display: none;" id="dialog" class="window">
<img src="http://dummyimage.com/1635x1085/000/fff" />
<a href="#" class="close">Close it</a>
</div>
<!-- Mask to cover the whole screen -->
<div style="display: none; opacity: 0.8;" id="mask"></div>
</div>

CSS

#mask {
  position:absolute;
  left:0;
  top:0;
  width:100%;
  height:100%;
  z-index:9000;
  background-color:#000;
  display:none;
}  
#boxes .window {
  position:absolute;
  left:0;
  top:0;
  display:none;
  z-index:9999;
}
#boxes .window img {width:100%;}
#boxes #dialog {
  width:80%; 
  height:80%;
  background-color:none;
}

JavaScript

$(document).ready(function() {	

		var id = '#dialog';
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':100%,'height':100%});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 	
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});		
	
});