Learn how to make dimmer effect on HTML page to make user focused on a message that we display it on the page.
Sorry this video is split into two parts because my recording was interrupted.
You can grab the source code here:
<!DOCTYPE html>
<html>
<head>
<title>ZK Tutorials</title>
<style>
#dimmer{
background-color: rgba(0, 0, 0, 0.75);
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: none;
}
#message{
position: fixed;
top: 150px;
left: 150px;
right: 150px;
bottom: 150px;
background-color: white;
display: none;
}
</style>
</head>
<body>
<h1>Lorem Impsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<button onclick="showMessage()">Click Me</button>
<div id="dimmer" onclick="hideMessage()"></div>
<div id="message">
Please read this message. Bla bla bla...
</div>
<script>
function showMessage(){
document.getElementById("dimmer").style.display = "block";
document.getElementById("message").style.display = "block";
}
function hideMessage(){
document.getElementById("dimmer").style.display = "none";
document.getElementById("message").style.display = "none";
}
</script>
</body>
</html>