<div class="container1">
<img src="https://i.telegraph.co.uk/multimedia/archive/02227/bristol_2227246i.jpg" width="100%" height="auto">
<div class="filter1">
</div>
<h1>This is an image</h1>
</div>
<div class="container2">
<img src="https://i.telegraph.co.uk/multimedia/archive/02227/bristol_2227246i.jpg" width="100%" height="auto">
<div class="filter2">
</div>
<h1>This is an image</h1>
</div>
.container1,
.container2 {
position: relative;
width: 600px;
}
img {
display: block;
width: 100%;
}
.filter1,
.filter2 {
position: absolute;
top: 0;
width: 100%;
height: 100%;
}
.filter1 {
background-image: linear-gradient(
rgba(180, 0, 25, 0.4),
rgba(180, 0, 25, 0.8)
);
transition: all .3s ease-in-out;
}
.filter2 {
background-image: linear-gradient(
rgba(0, 0, 100, 0.4),
rgba(0, 0, 0, 0.8)
);
transition: all .3s ease-in-out;
opacity: .7;
}
h1 {
position: absolute;
top: 50%;
width: 100%;
text-align: center;
color: white;
text-transform: uppercase;
letter-spacing: .04em;
transition: all .3s ease-in-out;
}
.container1:hover {
.filter1 {
opacity: .7;
}
h1 {
transform: translateY(-10px);
}
}
.container2:hover {
.filter2 {
opacity: 1;
}
h1 {
transform: scale(1.1) translateY(-5px);
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.