Learn how to create an overlay effect with CSS

Make money for being or staying online/internet.
You will get a $5 starting gift when you join using this link:: GET THE OFFER NOW!!
In this simple article you will learn how to create an overlay effect with CSS.
Overlay means to cover the surface of something with a transparent background. In other words, it is used to set one thing on the top of another.
The overlay makes a web-page attractive, Provides holds extra information for the user to take action and more so it is easy to design.
HTML - Markup
<div class="overlay"> <div class="info"> <div class="close" id="closeOverlay">×</div> <h2>Oston Code Cypher</h2> <p>Join me today and get your life time tutorials for FREE.</p> <button class="btn">Subscribe</button> </div> </div>
CSS - Styles
Having only this code targeting the element with the overlay class will create the effect.
.overlay{ width:100%; height:100%; background-color:rgba(0,0,0,0.9); position:fixed; top:0; left:0; right:0; bottom:0; z-index:2; display:none; }
The rest of the code I wrote was to style the layout or position of the elements I put in the inner div with the class of info.
Tutorial Code
body{ } .container{ max-width:80%; margin:0 auto; margin-top:20px; } .overlay{ width:100%; height:100%; background-color:rgba(0,0,0,0.9); position:fixed; top:0; left:0; right:0; bottom:0; z-index:2; display:none; } .info{ display:flex; flex-direction: column; align-items: center; justify-content: center; height:100vh; color:#fff; opacity:0; animation: channelInfo 1s ease-in 1.5s; animation-fill-mode:forwards; } .info h2{ margin-bottom:0; } .info p{ font-size:20px; } .close{ position: absolute; top:0; right:0; margin:20px 20px 0 0; transform:scale(2); transition:all 0.6s ease-in; } .close:hover{ color:#00796b; cursor: pointer; transform: scale(3) rotate(360deg); } .btn{ background-color:#00796b; color:#fff; padding:10px; border:0; border-radius:5px; box-shadow: -2px 3px 4px rgba(0,0,0,0.5); cursor: pointer; transition: background-color 0.5s ease-in-out; } .btn:hover{ background-color: tomato; } @keyframes channelInfo{ 0%{ opacity:0; } 100%{ opacity:1; } }
In this next post, I will add javascript to open and close the overlay.
Save up to 80% with this Domain & Shared Hosting package deal! 80% OFF - GET OFFER NOW
Related Post(s)
» Learn how to create Gradient Backgrounds using CSS
» Animated Social Media Icons Using Font Awesome and Materialize CSS
» Overriding The Default Text Selection Color With CSS
» Learn how to use CSS box shadow property - Source Code
» How do I wrap text in a pre tag?[SOLVED]
collections_bookmark Category :: Cssdate_range Published :: 1 year ago At: 12:03 AM
event_note Detailed Date :: Jun 21st, 2020
person Writer :: Code
- RECENT POSTS

A JavaScript library for formatting and manipulating numbers - Numeral.js
Check out this lightweight JavaScript library used for formatting and manipulating numbers.

All Countries Drop Down List | HTML Select Country Name
This simple country dropdown list is freely available for you to copy and use in your project forms.

HTML Entities Code Alphabet Discovery Using JavaScript
In this post I will show how writing just a few lines in JavaScript will allow you to render, browse and discover the alphabetical letters using a set of HTML entity codes.

YTS YIFY MOVIES API - PROJECT PREVIEW
Download YTS YIFY movies using this simple project I created using their API.

Display Random Advice On Your Website or Web App Using Advice Slip JSON API
Here is a short project to display the use of APIs. I decided to work with an advice API because it seemed like a fun one that I haven't worked on before.

How do I get a YouTube video thumbnail from YouTube using PHP
Have you ever been on youtube and admired a thumbnail of a video?

How to recreate Facebook's console warning
When I was inspecting some code on Facebook. I came across this interesting feature. A simple styled console warning message from Facebook to its dear users(products).

How To Create A Stacked Gallery Using HTML And CSS Source Code
In this post I provide you with the source code for the youtube tutorial I made on how to create a Stacked image gallery Using HTML and CSS.
- ADVERTISEMENT