Overlay CSS Techniques

Overlay CSS Techniques

In an HTML designing layout, there are too many different types of CSS that HTML designers used for making their website looking good. So today I am just talking about Overlay CSS. Sometimes you stuck for making an overlay content, but I am sure after reading this blog post your issue will be solved.

Let’s start about overlay  CSS-

overlay - Overlay CSS Techniques

There is simple technique for creating overlay –

Absolutely positioned:

This is the CSS which is needed to make an overlay effect.

.overlay {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgba(0,0,0,0.5);
}
1) In the above CSS overlay is the class name which is used for making an overlay.
2) Position: absolute, is used for absolute position for the overlay.
3) height and width take 100% for showing overlay effect in full area.
4) background-color: rgba(0,0,0,0.5) if you want to show color then you can take any color for the background. Otherwise, you can take any text.

The following CSS code shows how to transparent color overlay on images. Also, you can see how to overlay one div over another div.

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
	.flower{
		width:320px;
		height:240px;
		background: url(img/tulip.jpg) no-repeat;
	}
	.flower .color{
		position:relative;
		top:0px;
		width:320px;
		height:240px;
		background:#fff;
		opacity:0;
	}
	.flower:hover .color
	{
		opacity:0.7;
	}
</style>
</head>
<body>

 

 Here is the output.

12 1 300x231 - Overlay CSS Techniques

White Overlay Image –

For adding white overlay just need to some changes in Code. See below –

 

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
	.flower{
		width:320px;
		height:240px;
		background: url(img/tulip.jpg) no-repeat;
	}
	.flower:hover{
		width:320px;
		height:240px;
		background:#fff;
		opacity:0.9;
	}
</style>
</head>
<body>

Position one image on top of another –

The Below CSS code shows how to overlaying image on another image.

By use of this CSS, you can change the image after hovering on one image. This looks so cool.

<!DOCTYPE html>
<html >
<head>
<style type="text/css">
	.Overlay
	{
		width: 240px;
		height: 240px;
		background: url(imges/image1.jpg) no-repeat;
	}
	.Overlay:hover {
		background: url(imges/image2.jpg) no-repeat;
	}
</style>
</head>
<body>

For more overlay effects you can try w3schools image overlay technique.

Subscribe to this blog to get latest post direct into your inbox.

Share the Article

About author
Darshan Saroya

Darshan Saroya

A passionate WordPress Theme Developer. I love to create clean and modern themes, using the power of WordPress. Here I provide the tutorials related to WordPress Development, Core PHP and HTML.