Adding a color overlay onto a background image can create a very nice effect. Traditionally, web designers added the overlay offline — using Photoshop or GIMP — and then uploaded the image with an overlay to the website. However, with CSS, you can add a color overlay to a background image with a few simple steps.

There are a number of ways to accomplish a color overlay on a background image using CSS. I’m going to show you how to add a linear gradient overlay to just the background image. You could get a similar result using multiple divs, but this method targets the background image specifically & separately from the div.

Let’s take a look at this example div below:

Two roads diverged in a wood, and I—
I took the one less traveled by,
And that has made all the difference.

As you can see, I’ve added a linear gradient overlay that goes from a light blue shade to light yellow. When you hover over the div, the gradient flips & transitions from yellow to blue. This effect adds a little pop to any image.

To use this code on your own site, just add div with the class bg-img or change the class in the above CSS to reflect your own.

Happy coding!

Do you prefer another method? Let me know in the comments below.
Are you looking for other overlay effects or want a tutorial on something else? Leave a comment or send me a message.

Pin It on Pinterest

Share This

Share this post with your friends!