JSFiddle - React, Tailwind, and code Playground
by wilnet
HTML
<div id="boxes">
<div id="dialog" class="window">
<div class="d-header">
<input type="text" value="nome" onclick="this.value=''"/><br/>
<input type="text" value="email" onclick="this.value=''"/>
</div>
<div class="d-blank"></div>
<div class="d-login"><input class="close" type="button" value="Enviar"/></div>
</div>
<!-- Máscara para cobrir a tela -->
<div id="mask"></div>
</div>
CSS
#mask {
position:absolute;
left:0;
top:0;
z-index:9000;
background-color:#000;
display:none;
}
#boxes .window {
position:absolute;
left:0;
top:0;
width:440px;
height:200px;
display:none;
z-index:9999;
padding:20px;
}
#boxes #dialog {
width:375px;
height:203px;
}
#dialog .d-header {
width:375px;
height:150px;
}
#dialog .d-header input {
position:relative;
top:60px;
left:100px;
border:3px solid #cccccc;
height:22px;
width:200px;
font-size:15px;
padding:5px;
margin-top:4px;
}
#dialog .d-blank {
float:left;
width:267px;
height:53px;
}
#dialog .d-login {
float:left;
width:108px;
height:53px;
}
.close{display:block; text-align:right;}
JavaScript
function open_modal( id ){
var maskHeight = $(document).height();
var maskWidth = $(window).width();
$('#mask').css({'width':maskWidth,'height':maskHeight});
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
$(id).fadeIn(2000);
};
$(document).ready(function() {
$('a[name=modal]').click(function(e) {
e.preventDefault();
open_modal( $(this).attr('href') );
});
open_modal( '#dialog' );
$('.window .close').click(function (e) {
e.preventDefault();
$('#mask').hide();
$('.window').hide();
});
});