Skip to content

ThirteeNov

My personal blog about coding and internet

Menu
  • About me
  • About Zofia Kreasi
  • Cart
  • Checkout
  • Making an airplane game from scratch in Unity
  • My account
  • Privacy Policy
  • Privacy Policy – zkLeaderboard
  • Sample Page
  • Shop
  • Tutorials on Learning JavaScript
  • ZKAccounts – Privacy Policy
Menu

How to make dimmer (appears darker) effect on HTML page

Posted on January 5, 2018August 4, 2020 by Habibie

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>
Post Views: 373
ciihuy2020

Welcome!

  • My YouTube Channel
  • My GitHub Page
  • About me

Categories

  • 3DVista
  • Android
  • Apache
  • C#
  • Cordova
  • Electron & Node JS
  • HTML5, CSS & JavaScript
  • iOS
  • Let's Make Unity Games
  • Misc
  • Photoshop
  • PHP
  • Python
  • Uncategorized
  • Unity
  • WordPress

Recent Posts

  • Hover Reveal script for Unity to show and hide object on mouse hover
  • How to Prevent UI Clicks in Unity from “Bleeding Through” to 3D Objects Behind Them
  • Make objects like wires and cables easily in Unity using Ciihuy Curved Mesh
  • [SOLVED] Can’t Add Custom Domain to Blogger After Losing CNAME Verification
  • iOS App Icon Generator by CiihuyCom
© 2026 ThirteeNov | Powered by Superbs Personal Blog theme