Added a dialog example

This commit is contained in:
Tapas Adhikary 2020-11-16 10:30:05 +05:30
parent ef1fe53dd5
commit 9789746303
3 changed files with 65 additions and 1 deletions

49
dialog/index.html Normal file
View File

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>HTML Tips and Tricks - Dialog Tag</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link href="https://fonts.googleapis.com/css2?family=Chilanka&display=swap" rel="stylesheet">
<link rel='stylesheet' type='text/css' media='screen' href='../main.css'>
</head>
<body>
<div class="demo">
<a href="../index.html" class="home">
<img src="../home.svg" alt="home" />
</a>
<h1>Dialog Tag</h1>
<!-- Trigger/Open The Modal -->
<button id="openDlg">Open Dialog</button>
<dialog id="dialog">
<form method="dialog">
<h2>I'm a Dialog</h2>
<p>What do you think of me?</p>
<menu>
<button>Close me</button>
</menu>
</form>
</dialog>
</div>
<script>
// Get the modal
const dialog = document.getElementById("dialog");
const btn = document.getElementById("openDlg");
// When the user clicks the button, open the dialog
btn.onclick = function() {
dialog.showModal();
}
</script>
</body>
</html>

View File

@ -71,6 +71,10 @@
<a href='./meter/index.html'>
Meter and Progress</a> - Display a gauge
</li>
<li>
<a href='./dialog/index.html'>
Dialog</a> - Display a Modal Dialog
</li>
</ul>
</div>
</body>

View File

@ -63,4 +63,15 @@ li {
.demo .range output {
font-size: 62px;
}
}
dialog::backdrop {
background: repeating-linear-gradient(
45deg,
rgba(0, 0, 0, 0.2),
rgba(0, 0, 0, 0.2) 1px,
rgba(0, 0, 0, 0.3) 1px,
rgba(0, 0, 0, 0.3) 20px
);
backdrop-filter: blur(3px);
}