Instead of setting the background color on the image, install it in the image container.
When the image freezes, apply opacity, which gives the image transparency, and you can see the background color in the container.
.article-preview-image {
display: inline-block;
background-color: red;
}
.article-preview-image img {
transition: .3s ease-in-out;
}
.article-preview-image:hover img {
opacity: 0.5;
}
modified code
source
share