Skip to content

Commit 9789746

Browse files
committed
Added a dialog example
1 parent ef1fe53 commit 9789746

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

dialog/index.html

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset='utf-8'>
6+
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
7+
<title>HTML Tips and Tricks - Dialog Tag</title>
8+
<meta name='viewport' content='width=device-width, initial-scale=1'>
9+
<link href="https://fonts.googleapis.com/css2?family=Chilanka&display=swap" rel="stylesheet">
10+
<link rel='stylesheet' type='text/css' media='screen' href='../main.css'>
11+
</head>
12+
13+
<body>
14+
<div class="demo">
15+
<a href="../index.html" class="home">
16+
<img src="../home.svg" alt="home" />
17+
</a>
18+
<h1>Dialog Tag</h1>
19+
<!-- Trigger/Open The Modal -->
20+
<button id="openDlg">Open Dialog</button>
21+
22+
<dialog id="dialog">
23+
<form method="dialog">
24+
<h2>I'm a Dialog</h2>
25+
<p>What do you think of me?</p>
26+
<menu>
27+
<button>Close me</button>
28+
</menu>
29+
</form>
30+
</dialog>
31+
32+
</div>
33+
<script>
34+
// Get the modal
35+
const dialog = document.getElementById("dialog");
36+
37+
const btn = document.getElementById("openDlg");
38+
39+
// When the user clicks the button, open the dialog
40+
btn.onclick = function() {
41+
dialog.showModal();
42+
}
43+
44+
45+
</script>
46+
47+
</body>
48+
49+
</html>

index.html

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ <h1>HTML5 Feature Tips</h1>
7171
<a href='./meter/index.html'>
7272
Meter and Progress</a> - Display a gauge
7373
</li>
74+
<li>
75+
<a href='./dialog/index.html'>
76+
Dialog</a> - Display a Modal Dialog
77+
</li>
7478
</ul>
7579
</div>
7680
</body>

main.css

+12-1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,15 @@ li {
6363

6464
.demo .range output {
6565
font-size: 62px;
66-
}
66+
}
67+
68+
dialog::backdrop {
69+
background: repeating-linear-gradient(
70+
45deg,
71+
rgba(0, 0, 0, 0.2),
72+
rgba(0, 0, 0, 0.2) 1px,
73+
rgba(0, 0, 0, 0.3) 1px,
74+
rgba(0, 0, 0, 0.3) 20px
75+
);
76+
backdrop-filter: blur(3px);
77+
}

0 commit comments

Comments
 (0)