<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modal Dialog</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #f0f2f5;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
justify-content: center;
align-items: center;
}
.modal-content {
background-color: white;
padding: 20px;
border-radius: 8px;
width: 300px;
text-align: center;
}
.modal-content button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: white;
font-size: 1em;
cursor: pointer;
}
.modal-content button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<button onclick="openModal()">Open Modal</button>
<div id="myModal" class="modal">
<div class="modal-content">
<h2>Modal Title</h2>
<p>This is a simple modal dialog.</p>
<button onclick="closeModal()">Close</button>
</div>
</div>
<script>
function openModal() {
document.getElementById('myModal').style.display = 'flex';
}
function closeModal() {
document.getElementById('myModal').style.display = 'none';
}
</script>
</body>
</html>