Certainly! Below is a complete HTML example that shows a full-screen popup displaying a promotional image. The popup will cover the entire viewport, with a semi-transparent dark background, and a close button to dismiss it.
You can customize the promotional image URL and styles as needed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Full Screen Popup Promotional Image</title>
<style>
/* Popup overlay styles */
#promoPopup {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
/* Container for image and close button */
#promoContent {
position: relative;
max-width: 90vw;
max-height: 90vh;
box-shadow: 0 0 20px rgba(0,0,0,0.7);
border-radius: 10px;
overflow: hidden;
background-color: #fff;
}
/* Promotional image styling */
#promoContent img {
display: block;
max-width: 100%;
max-height: 100%;
height: auto;
width: auto;
object-fit: contain;
}
/* Close button */
#closeBtn {
position: absolute;
top: 10px;
right: 10px;
background-color: rgba(255,255,255,0.8);
border: none;
font-size: 24px;
font-weight: bold;
cursor: pointer;
padding: 5px 10px;
border-radius: 5px;
transition: background-color 0.3s;
}
#closeBtn:hover {
background-color: rgba(255,255,255,1);
}
</style>
</head>
<body>
<!-- Full screen popup -->
<div id="promoPopup">
<div id="promoContent">
<button id="closeBtn" aria-label="Close promotional popup">×</button>
<img src="https://via.placeholder.com/800x600.png?text=Promotional+Image" alt="Promotional Banner" />
</div>
</div>
<script>
// Get popup and close button elements
const promoPopup = document.getElementById('promoPopup');
const closeBtn = document.getElementById('closeBtn');
// Close popup on button click
closeBtn.addEventListener('click', () => {
promoPopup.style.display = 'none';
});
// Optional: Close popup if user clicks outside the image area
promoPopup.addEventListener('click', (event) => {
if(event.target === promoPopup) {
promoPopup.style.display = 'none';
}
});
// Optional: You can add code here to delay showing the popup or show only once per session
</script>
</body>
</html>
How it works:
- The
#promoPopup div covers the entire viewport, with a dark transparent background.
- Centered inside is the
#promoContent, containing the image and a close button.
- Clicking the close button or clicking outside the image closes the popup by setting its
display to none.
- The promotional image by default uses a placeholder URL — replace
src with your actual promotional image URL.
Feel free to ask if you want additional features like animations or delayed popup!