<!-- Hidden checkbox to toggle the modal -->
<input type="checkbox" id="modal-toggle">
<!-- Button to open the modal -->
<label for="modal-toggle" style="cursor: pointer;">Open Modal</label>
<!-- The Modal -->
<div class="modal">
<div class="modal-content">
<a href="#" class="close" onclick="document.getElementById('modal-toggle').click();">×</a>
<h2>Modal Title</h2>
<p>This is a simple modal dialog without JavaScript!</p>
</div>
</div>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
/* Hide the checkbox */
#modal-toggle {
display: none;
}
/* The modal background */
.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;
}
/* Show the modal when the checkbox is checked */
#modal-toggle:checked ~ .modal {
display: flex;
}
/* The modal content */
.modal-content {
background-color: white;
padding: 20px;
border-radius: 5px;
max-width: 500px;
width: 100%;
text-align: center;
position: relative;
}
/* The close button */
.close {
position: absolute;
top: 10px;
right: 10px;
font-size: 24px;
text-decoration: none;
color: #333;
cursor: pointer;
}
.close:hover {
color: #ff4c4c;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.