As you said that a response only with CSS could suit you, here I will leave a technique. The principle here is that the btn Close actually is a label
linked in a input:radio
that when checkado
makes the div
downhill disappear.
See that I put a small delay in the entrance of the modal, but in the animation
you can control this value whether you want it to take longer or not. Note also that when the modal is active you can not select anything below, nor click anything (This for the layman).
I tried to make the model as simple as possible to make it easier to understand. I left comments in the code.
Take the example.
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#rd {
display: none;
}
input[id="rd"]:checked + div.bg {
display: none;
z-index: -1000;
opacity: 0;
}
.bg {
position: fixed;
top: 0;
left: 0;
z-index: 100;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
/* remover animação se quiser que ele aparece direto sem delay */
-webkit-animation: tempo 500ms ease-in 250ms forwards;
animation: tempo 500ms ease-in 250ms forwards;
}
.box {
background-color: red;
width: 100px;
height: 100px;
display: flex;
justify-content: center;
align-items: center;
}
.box label {
background-color: #fff;
width: 50px;
height: 30px;
line-height: 30px;
text-align: center;
display: inline-block;
cursor: pointer;
}
/* remover se remover a animação do modal */
@-webkit-keyframes tempo {
to {
opacity: 1;
}
}
@keyframes tempo {
to {
opacity: 1;
}
}
<!-- modal -->
<input type="radio" id="rd">
<div class="bg">
<div class="box">
<label for="rd">fechar</label>
</div>
</div>
<!-- conteudo de Exemplo -->
<table border="1">
<tr>
<td>100px</td>
<td>200px</td>
</tr>
</table>
<input type="submit">
<input type="text">
Face to do this only with CSS in a simple way, if you want I make an example for you.
– hugocsl
It would help me a lot thanks
– Guilherme Henrique