-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo2.html
More file actions
48 lines (43 loc) · 1.05 KB
/
demo2.html
File metadata and controls
48 lines (43 loc) · 1.05 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
<html>
<head>
<meta charset="UTF-8">
<title>backdropクリックで閉じる</title>
<style>
body {
font-family: sans-serif;
}
dialog {
padding: 0;
border: 1px solid #ccc;
max-width: 320px;
}
dialog > div {
padding: 32px;
}
dialog::backdrop {
background: rgb(0 0 0 / 0.4);
}
</style>
</head>
<body>
<button onclick="modalDefault.showModal()">通常のモーダル(backdropクリックで閉じない)</button>
<button onclick="modalBackdrop.showModal()">backdropクリックで閉じるモーダル</button>
<dialog id="modalDefault">
<div>
<p>backdropをクリックしても閉じません。</p>
<button onclick="modalDefault.close()">閉じる</button>
</div>
</dialog>
<dialog
id="modalBackdrop"
closedby="any"
onclick="event.target === event.currentTarget && event.currentTarget.close()"
>
<div>
<!-- インナーの div は stopPropagation のために必要 -->
<p>backdropをクリックすると閉じます。</p>
<button onclick="modalBackdrop.close()">閉じる</button>
</div>
</dialog>
</body>
</html>