I'm using top: 50%;
but I do not focus vertically on the modal window, what's the problem?
CODE:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Simple Modal</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="css/style.css">
<style type="text/css">
.container {
width: 800px;
height: auto;
margin: auto;
}
.notice {
position: relative;
top: 50%;
width: 90%;
height: 200px;
border-radius: 15px;
background: #fff;
margin: auto;
z-index: 1;
}
.notice p {
padding: 15px 40px;
}
.close {
width: 25px;
height: 25px;
background: #fff;
position: absolute;
text-align: center;
right: -7px;
top: -7px;
border-radius: 50%;
cursor: pointer;
}
.close img{
margin-top: 6px;
margin-left: 1px;
width: 12px;
}
.modal {
position: fixed;
background: rgba(0,0,0,0.7);
top: 0;
bottom: 0;
right: 0;
left: 0;
}
.modal,
.notice {
display: none;
}
.bar-title{
width: 100%;
background: #ec4b4b;
border-radius: 15px 15px 0 0;
padding: 15px 0
}
.bar-title span{
color: #fff;
margin-left: 30px;
font-weight: 700
}
</style>
</head>
<body>
<div class="container">
<a href="#" class="btn">Ativar Modal</a>
</div>
<div class="modal"></div>
<div class="notice">
<div class="close"><img src="img/close-button.png" alt=""></div>
<div class="bar-title">
<span>TITULO</span>
</div>
<p>Conteido</p>
</div>
<script>
$(document).ready(function(){
$('.container a').click(function(){
$('.modal,.notice').fadeIn(500,function(){});
});
$('.close,.modal').click(function(){
$('.modal,.notice').fadeOut(500,function(){});
});
$(document).keyup(function(e) {
if (e.keyCode == 27) {
$('.modal,.notice').fadeOut(500,function(){});
}; // esc
});
});
</script>
</body>
</html>