CSS images overlay
CSS Tutorial » CSS images overlay
What is CSS overlay?Overlay in webdesign means covering the surface of an element with something. In other words, it is used to put one thing on top of another.
The overlay makes the web page attractive and easy to design.
Useing CSS3 you can add overlay to an element.
In this chapter you will learn about How to overlay an image.
Internal - by using a <style> element in the <head> section
External - by using an external CSS Style file as style.css
How to Create Image Overlay Hover using HTML - CSS ?
How to Create Image Overlay Hover CSS
To display the overlay fade in a box on mouse hover, we design the HTML - CSS code from the beginning.For a better understanding we present an example:
<!DOCTYPE html>
<html>
<head>
<title>How do I overlay an image in a div? </title>
<style>
.container {
position: relative;
width: 50%;
}
.image {
opacity: 1;
display: block;
width: 90%;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
}
.middle {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
.text {
background-color: #04AA6D;
color: white;
font-size: 16px;
padding: 16px 32px;
}
.container:hover .image {
opacity: 0.3;
}
.container:hover .middle {
opacity: 1;
}
</style>
</head>
<body><h2>How do I overlay an image in a div?
</h2>
<p>Hover over the image to see the effect.</p><div class="container">
<img class="image" style="width:100%"
src="https://www.agernic.com/images/background-img.jpg" />
<div class="middle">
<div class="text">My background image.<br />
How do I overlay one div over another in CSS?</div>
</div>
</div>
</body>
</html>
Related subjects:
CSS align image center
CSS rounded corners image
CSS image
CSS image center
CSS image shadow
CSS image overlay on hover
In the following chapters we go deeper:
How do you overlay images on hover?
How do I overlay an image in CSS?
How do you make text appear when hovering over an image in CSS?
How do I add a black overlay to an image in CSS?
CSS image overlay animation
Tags: css image overlay: on hover, gradient, effects, color, fade, animation, text, another image, darken
CSS images overlay - css tutorial
This tool makes it easy to create, adjust, and experiment with custom colors for the web.

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.

Find here examples of creative and unique website layouts.

Find here examples of creative and unique website CSS HTML menu.