-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel_popup.html
More file actions
65 lines (57 loc) · 1.46 KB
/
model_popup.html
File metadata and controls
65 lines (57 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<button class="open-modal">Open Modal</button>
<div class="modal">
<div class="modal-content">
<span class="close-modal">×</span>
<h2>Modal Title</h2>
<p>This is a fully animated modal popup.</p>
</div>
</div>
<style>
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
visibility: hidden;
transition: 0.3s;
}
.modal-content {
background: white;
padding: 20px;
border-radius: 8px;
width: 300px;
text-align: center;
transform: scale(0.7);
transition: 0.3s;
}
.modal.show {
opacity: 1;
visibility: visible;
}
.modal.show .modal-content {
transform: scale(1);
}
.close-modal {
position: absolute;
right: 15px;
top: 10px;
font-size: 20px;
cursor: pointer;
}
</style>
<script>
const modal = document.querySelector(".modal");
const openBtn = document.querySelector(".open-modal");
const closeBtn = document.querySelector(".close-modal");
openBtn.onclick = () => modal.classList.add("show");
closeBtn.onclick = () => modal.classList.remove("show");
window.onclick = (e) => {
if (e.target === modal) modal.classList.remove("show");
};
</script>