CSS Introduction

CSS Tutorial What is CSS CSS Syntax CSS Selector How to include CSS CSS Comments

CSS Attributes

CSS Background CSS Border CSS Display CSS Float CSS Font CSS Color CSS Hover CSS Important CSS Line-height CSS Margin CSS Opacity CSS Filter CSS Images CSS Overflow CSS Padding CSS Position CSS Vertical align CSS White space CSS Width Word-wrap in CSS Box-shadow in CSS Text-transform in CSS CSS Outline CSS Visibility CSS Counters CSS Clear fix CSS Icons CSS Justify-content Text-decoration in CSS CSS Lists CSS nth selector CSS Sticky CSS Background-clip CSS Checkbox-style CSS Letter-spacing CSS Navigation bar CSS Overlay CSS Root CSS Specificity CSS Text-indent CSS Text-stroke CSS Zoom CSS Order CSS Descendent selector CSS Clip CSS calc() CSS Background-blend-mode CSS radio-button CSS Superscript and subscript CSS Text-effects CSS Text-align CSS Variables CSS Page-break-before CSS Page-break-inside CSS Page-break-after CSS Content property CSS Word-spacing CSS Animation CSS @keyframes rules CSS Pseudo-classes CSS Pseudo-elements CSS Radial-gradient CSS Translate CSS Gradients CSS z-index CSS Loaders CSS Units CSS Transition CSS Masking CSS Arrow CSS Pagination

Questions

What is Bootstrap CSS What is CSS used for How to center a table in CSS What is a CSS File How to center a button in CSS How to change background color in CSS How to change the font in CSS How to change font size in CSS How to resize an image in CSS How to get rid of bullet pioints in CSS Is CSS a programming language How to edit CSS in WordPress How to use google fonts in CSS How to create blinking text using CSS How to Set Space between the Flexbox Is CSS a Programming Language

Difference

Difference between HTML and CSS Grid Vs Flexbox in CSS Difference between CSS Grid and CSS Flexbox

Misc

Create a 3D text effect using HTML and CSS Hover condition for a:before and a:after in CSS Bem CSS Boder Types CSS Features of CSS Font Face CSS Image Overlay CSS B Tag CSS Carousel CSS CSS Arrow CSS Focus Flex Grow in CSS Bem CSS Features of CSS Font Face CSS Removing Underline from Link in CSS Width Property in CSS Radio Button in CSS

CSS Overlay

CSS Overlay: It measures to cover-up something’s surface along with a coating. CSS overlay sets anything over the top area of other things. It creates a web-page more attractive. The design is also quite easy.

Designing an overlay consequence specifies that putting two div elements together at any same place. Though, both the elements will present when required. If we create any second div element that occurs, we can click or hover over one div. One div element is an overlay div and includes what will display if any user hovers on the image. The second div element is any container that holds the images both and also its overlay.

Fade Overlay Effect

This overlay specifies that if we move the point of the cursor over an image, then it will display over the image’s top area. Let’s consider an example, given below:

Example:

<!DOCTYPE html>
<html>
<head>
<title> Image Overlay </title>
<style>
.container img
{
 width: 300px;
 height: 300px;
}
.container
{
 position: relative;
 width: 25%;
 height: auto;
}
.overlay
{
 position: absolute;
 transition: 0.5s ease;
 height: 300px;
 width: 100px;
 top: 0;
 left: 0;
 background-color: violet;
 opacity: 0;
}
.container:hover .overlay
{
 opacity: 0.9;
}
</style>
</head>
<body>
<center>
<h1> Fade Overlay Effect </h1>
<h2> Point the cursor on the image to feel the effect. </h2>
<div class= "container">
<img src= "Flower3.png">
<div class= "overlay"></div>
</div>
</center>
</body>
</html>

Output:

CSS Overlay

Image Overlay Slide

By using the image overlay slide, we can make any effect of sliding overlay with the help of four distinct types like left, right, top, and bottom. We will discuss it with an example.

Overlay Slide from top to bottom

Now, we will understand how to make a slide inside the overlay from any top surface with the help of an example.

Example:

<!DOCTYPE HTML>  
<html>  
<head>  
<style>  
.container img
{  
 width: 300px;  
 height: 300px;  
}  
.container
{  
 position: relative;  
 width: 25%;  
 height: auto;
}   
.container:hover .overlay
{  
 opacity: 0.8;  
 height: 300px;  
}  
.overlay
{  
 position: absolute;  
 transition: 0.7s ease;  
 opacity: 0;  
 width: 100px;  
 height: 0;  
 top: 0;  
 right: 20px;
 left: 0;  
 background-color: violet;  
}  
</style>  
</head>  
<body>  
<center>          
<h1> Overlay slide from top to bottom </h1> 
<h2> Point the cursor on the image to feel the effect. </h2> 
<div class="container">  
<img src= "Flower3.png">  
<div class="overlay"></div>  
</div>  
</center>  
</body>  
</html> 

Output:

CSS Overlay

Overlay Slide from bottom to top

When we point the cursor on any image, it will slide from the bottom to the top. To understand this, let’s assume an example.

Example:

<!DOCTYPE HTML>  
<html>  
<head>  
<style>  
.container img
{  
 width: 300px;  
 height: 300px;  
}  
.container
{  
 position: relative;  
 width: 25%;  
 height: auto;
}   
.container:hover .overlay
{  
 opacity: 0.8;  
 height: 300px;  
}  
.overlay
{  
 position: absolute;  
 transition: 0.7s ease;  
 opacity: 0;  
 width: 100px;  
 height: 0;  
 bottom: 0;  
 right: 20px;
 left: 0;  
 background-color: violet;  
}  
</style>  
</head>  
<body>  
<center>          
<h1> Overlay slide from bottom to top </h1> 
<h2> Point the cursor on the image to feel the effect. </h2> 
<div class="container">  
<img src= "Flower3.png">  
<div class="overlay"></div>  
</div>  
</center>  
</body>  
</html> 

Output:

CSS Overlay

Overlay Slide from left to right

As the name suggests, left to right sliding will be there. See the example below.

Example:

<!DOCTYPE HTML>  
<html>  
<head>  
<style>  
.container img
{  
 width: 300px;  
 height: 300px;  
}  
.container
{  
 position: relative;  
 width: 25%;  
 height: auto; 
}   
.container:hover .overlay
{  
 opacity: 0.8;  
 width: 300px;  
}  
.overlay
{  
 position: absolute;  
 transition: 0.7s ease;  
 opacity: 0;  
 width: 0;  
 height: 100%;  
 bottom: 0;  
 left: 20px;  
 background-color: violet;  
}  
</style>  
</head>  
<body>  
<center>  
<h1> Overlay slide from left to right </h1> 
<h2> Point the cursor on the image to feel the effect. </h2> 
<div class="container">  
<img src= "Flower3.png">  
<div class="overlay"></div>  
</div>  
</center>  
</body>
</html>  

Output:

CSS Overlay

Overlay Slide from right to left

This sliding method is quite similar to various effects, as mentioned above, except that it will slide from the right surface to the left surface.

Example:

<!DOCTYPE HTML>  
<html>  
<head>  
<style>  
.container img
{  
 width: 300px;  
 height: 300px;  
}  
.container
{  
 position: relative;  
 width: 25%;  
 height: auto; 
}   
.container:hover .overlay
{  
 opacity: 0.8;  
 width: 300px;  
}  
.overlay
{  
 position: absolute;  
 transition: 0.7s ease;  
 opacity: 0;  
 width: 0;  
 height: 100%;  
 bottom: 0;  
 right: 20px;  
 background-color: violet;
}  
</style>  
</head>  
<body>  
<center>  
<h1> Overlay slide from right to left </h1> 
<h2> Point the cursor on the image to feel the effect. </h2> 
<div class="container">  
<img src= "Flower3.png">  
<div class="overlay"></div>  
</div>  
</center>  
</body>
</html>  

Output:

CSS Overlay

Image Overlay title

In an image overlay consequence, if we point the cursor on the image, we can see a title over it. Consider the following illustration.

Example:     

<!DOCTYPE HTML>  
<html>  
<head>  
<meta name= "viewport" content= "width=device-width, initial-scale=1"> 
<style>
body
{  
 text-align: center;
}  
* {box-sizing: border-box;}
.container
{  
 position: relative;  
 width: 50%;  
 max-width: 300px;
}   
img
{
 display: block;
 width: 100%;
 height: auto;
}
.overlay
{  
 position: absolute;
 bottom: 0; 
 background: rgba(0, 0, 0, 0.2);
 width: 100%;
 opacity: 0;    
 transition: .9s ease;
 font-size: 25px;  
 padding: 20px;
}  
.container:hover .overlay
{  
 opacity: 1.5; 
}             
</style>  
</head>  
<body>  
<h1> Image Overlay Title Effect </h1> 
<h2> Point the cursor on the image to feel the effect. </h2>
<center>   
<div class= "container">  
<img src= "flower.png">  
<div class= "overlay"> Welcome to this Page </div>  
</div>  
</center>  
</body>
</html>  

Output:

CSS Overlay

Image Overlay icon

In this effect of the overlay, an icon over the mouse hovering will be there to cover the whole image. We will also set a link over the icon to swap between any pages. Consider the following illustration given below:

Example:

<!DOCTYPE HTML>  
<html>  
<head>  
<meta name= "viewport" content= "width=device-width, initial-scale=1"> 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> 
<style>
.container
{  
 position: relative;  
 width: 100%;  
 max-width: 400px;
}   
.img
{
 display: block;
 width: 100%;
 height: auto;
}
.overlay
{  
 position: absolute;
 top: 0; 
 height: 100%; 
 width: 100%; 
 opacity: 0; 
 transition: 1s ease; 
 background-color: violet;  
}  
.container:hover .overlay
{  
 opacity: 1; 
}      
.icon
{
 color: blue;
 font-size: 100px;
 position: absolute;
 top: 50%;
 left: 50%;
 transform: translate(-50%, -50%);
}      
</style>  
</head>  
<body>  
<center>         
<h1> Image Overlay icon Effect </h1> 
<h2> Point the cursor on the image to feel the effect. </h2>   
<div class= "container">  
<img src= "Flower3.png" class= "img">  
<div class= "overlay">
<a href= "#" class= "icon">
<i class= "fa fa-home"></i>
</a>
</div>  
</div>  
</center>  
</body>
</html>  

Output:

CSS Overlay