-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
93 lines (86 loc) · 2.82 KB
/
index.html
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Modal is an easy way</title>
<!-- styles -->
<style>
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.modal-wrapper {
padding: 50px;
}
button {
background: rgb(32, 32, 61);
color: #fff;
border-radius: 5px;
border: none;
padding: 8px 20px;
}
.modal {
padding: 1em;
max-width: 50ch;
border-radius: 8px;
}
.modal::backdrop {
background: purple;
opacity: 0.2;
}
</style>
</head>
<body>
<div class="modal-wrapper">
<h1>Modal is an easy way</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur
veniam sint quia ipsum temporibus amet est laborum error nisi,
facere modi voluptas nemo. Ad distinctio cum asperiores sit nisi
ratione!
</p>
<br />
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur
veniam sint quia ipsum temporibus amet est laborum error nisi,
facere modi voluptas nemo. Ad distinctio cum asperiores sit nisi
ratione!
</p>
<br />
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur
veniam sint quia ipsum temporibus amet est laborum error nisi,
facere modi voluptas nemo. Ad distinctio cum asperiores sit nisi
ratione!
</p>
<br />
<button class="open-button">Open modal</button>
<dialog class="modal" id="modal">
<h2>Lorem ipsum dolor sit amet.</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore
harum qui, error voluptatibus magni placeat.
</p>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore
harum qui, error voluptatibus magni placeat.
</p>
<button class="close-button">Close modal</button>
</dialog>
</div>
<script>
const modal = document.querySelector('.modal');
const openModal = document.querySelector('.open-button');
const closeModal = document.querySelector('.close-button');
openModal.addEventListener('click', () => {
modal.showModal();
});
closeModal.addEventListener('click', () => {
modal.close();
});
</script>
</body>
</html>