HTML
<h1>Ventana Modal</h1>
<a href="#modal" id="show-modal">Abrir Ventana</a>
<aside id="modal" class="modal">
<div class="content-modal">
<header>
<a href="#" class="close-modal">X</a>
<h2>Buen Trabajo!</h2>
</header>
<article></article>
</div>
<a href="#" class="btn-close-modal"></a>
</aside>CSS
body{
background-color: #3e2525;
font-family: sans-serif;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
padding-top: 10em;
position: relative;
text-align: center;
}
h1 {
color: white;
padding: 1em;
}
#show-modal{
text-align: center;
background: #bc651a;
padding: 15px 15px;
color: white;
font-weight: 100;
font-size: 1.5em;
border-radius: 3.5px;
text-decoration: none;
transition: all 0.15s linear;
}
#show-modal:hover{
cursor: pointer;
background: #bc9d1a;
}
.modal{
position: fixed;
top: -100vh;
left: 0;
z-index: 99999999;
background: rgba(0, 0, 0, 0.75);
width: 100vw;
height: 100vh;
opacity: 0;
transition: opacity 0.35s ease;
}
.modal .content-modal{
width: 100%;
max-width: 500px;
position: fixed;
left: 50%;
top: -100vh;
transition: top 0.35s ease;
margin-left: -250px;
background: white;
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
border-radius: 2px;
z-index: 9999999;
}
.modal h2{
padding: 0.5em;
text-align: center;
color: #444444;
margin: 0;
}
.modal article{
height: 300px;
background: #bc651a;
}
.close-modal{
color: #e74c3c;
position: absolute;
top: 0.2em;
right: 0.375em;
margin: 0;
padding: 5px;
font-weight: bold;
font-size: 1.5em;
text-decoration: none;
}
.modal a:hover{
color: #c0392b;
}
.modal:target{
opacity: 1;
top: 0;
}
.modal .btn-close-modal{
position: absolute;
left: 0;
width: 100%;
height: 100%;
z-index: 99999991;
}
.modal:target .content-modal{
top: 50px;
transition: top 0.35s ease;
}
@media (max-width: 500px){
.modal .content-modal{
width: 90%;
max-width: none;
left: 5%;
margin-left: 0;
}
}
Deja tu comentario