Skip to content

Commit aad2d16

Browse files
committed
Janela Modal
1 parent 0623b5d commit aad2d16

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed

janela-modal.html/index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html lang="pt-br">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="style.css">
8+
<title>Janela Modal com JavaScript</title>
9+
</head>
10+
<body>
11+
12+
<div onclick="openModal()" class="btn">Clique aqui</div>
13+
14+
<div id="modal-container" class="modal-container">
15+
<div class="modal">
16+
<button class="fechar" id="fechar">X</button>
17+
<h1>Olá, mundo</h1>
18+
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Harum soluta, nobis adipisci aperiam molestiae, qui nostrum esse id deserunt aliquam perferendis? Ad dolor distinctio accusamus laudantium error similique obcaecati hic.</p>
19+
20+
<iframe width="560" height="315" src="https://www.youtube.com/embed/fu-enUG2VEE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
21+
</div>
22+
</div>
23+
24+
<script src="script.js"></script>
25+
</body>
26+
</html>

janela-modal.html/script.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function openModal(){
2+
const modal = document.getElementById('modal-container')
3+
modal.classList.add('mostrar')
4+
5+
modal.addEventListener('click', (e) =>{
6+
if (e.target.id == 'modal-container' || e.target.id == "fechar"){
7+
modal.classList.remove('mostrar')
8+
localStorage.fechaModal = 'modal-container'
9+
}
10+
})
11+
}

janela-modal.html/style.css

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
*{
2+
margin: 0;
3+
padding: 0;
4+
box-sizing: border-box;
5+
font-family: "Outfit", sans-serif;
6+
}
7+
8+
body{
9+
width: 100%;
10+
height: 100vh;
11+
}
12+
13+
.btn{
14+
padding: 25px 60px;
15+
display: inline;
16+
background-color: tomato;
17+
border-radius: 20px;
18+
color: #fff;
19+
font-size: 20px;
20+
cursor: pointer;
21+
transition: background-color 0.5s;
22+
position: absolute;
23+
top: 50%;
24+
left: 50%;
25+
transform: translate(-50%, -50%);
26+
z-index: 1;
27+
}
28+
29+
.btn:hover{
30+
background-color: #ff4c2c;
31+
}
32+
33+
.modal-container{
34+
width: 100vw;
35+
height: 100vh;
36+
position: fixed;
37+
top: 0;
38+
left: 0;
39+
background-color: #0000004b;
40+
z-index: 999;
41+
align-items: center;
42+
justify-content: center;
43+
display: none;
44+
}
45+
46+
.modal{
47+
width: 60%;
48+
min-width:400px;
49+
min-height: 200px;
50+
background-color: #ffffff62;
51+
backdrop-filter: blur(10px);
52+
padding: 20px;
53+
border-radius: 10px;
54+
}
55+
56+
.fechar{
57+
position: absolute;
58+
top: -10px;
59+
right: -10px;
60+
width: 30px;
61+
height: 30px;
62+
border-radius: 50%;
63+
border: none;
64+
background-color: #ff0000;
65+
color: #fff;
66+
font-weight: 700;
67+
font-size: 14pt;
68+
cursor: pointer;
69+
}
70+
71+
@keyframes animate-modal {
72+
from{
73+
opacity: 0;
74+
transform: translate3d(0, -20px, 0);
75+
}
76+
77+
to{
78+
opacity: 1;
79+
transform: translate3d(0, 0, 0);
80+
}
81+
}
82+
83+
.modal-container.mostrar{
84+
display: flex;
85+
}
86+
87+
.mostrar .modal{
88+
animation: animate-modal .3s;
89+
}

0 commit comments

Comments
 (0)