DEV Community

Cover image for Two ways to create an image with a colour overlay in CSS

Two ways to create an image with a colour overlay in CSS

Ellen Macpherson on September 29, 2019

Using an image with a dark overlay is one of the quickest ways to make a beautiful hero header for a blog, landing page or portfolio. It's a trick ...
Collapse
 
sonawaneapekshit profile image
sonawaneapekshit

We can also use a solution like below but it will require some what more CSS.
Here is the link: codepen.io/sonawaneapekshit/pen/Rw...

Collapse
 
timonwa profile image
Timonwa Akintokun

I have never thought about doing it this way b4. It's usually the two mentioned in the post. Thanks for sharing this.

Collapse
 
karenefereyan profile image
Efereyan Karen Simisola

This was so helpful to me Ellen. Thank you

Collapse
 
drozumek profile image
Damian Rozumek

The first method won't work. You have to position absolutely img or section tag. Otherwise the img will fit all the available space and push section tag with text out out the view.

Collapse
 
gracefrank profile image
Grace Frank

yea, I tried it, the section was at the bottom. and now I have to give the section positioning

Collapse
 
felipperegazio profile image
Felippe Regazio

pretty cool, ellen!

Collapse
 
ellen_dev profile image
Ellen Macpherson

Cheers, Felippe!

Collapse
 
weptim profile image
WEPUKHULU TIMOTHY

How can you use it with a video background

Collapse
 
ellen_dev profile image
Ellen Macpherson

I don't work with videos too often, but theres a solution here: stackoverflow.com/questions/489620...

Collapse
 
bam92 profile image
Abel Lifaefi Mbula

Typo: VIOLA, should be VOILA.

Collapse
 
dominic profile image
Dom

I used this post today for a project! thanks Ellen

Collapse
 
enieber profile image
Enieber Cunha

this solution is very elegant, thanks...

Collapse
 
deolawage profile image
Deolawage

Hi, Thanks for the Tip really helpful

Collapse
 
mooktar profile image
mooktar

Thank you for this tutorial. It's very helpful πŸ‘

Collapse
 
adisaktijrs_dev profile image
Adi Sakti Jrs

Ah, genius! Big thanks

Collapse
 
gaspar profile image
Diogo Gaspar

Thank you, helped me a lot.

Collapse
 
courtneypure profile image
C. Pure

Thanks for this post! I’m excited to try this out and spice up my portfolio site πŸ‘©πŸ½β€πŸ’»πŸ‘πŸΌπŸ‘πŸΌ

Collapse
 
sbateswar profile image
Stanley Bateswar

Cool!

Collapse
 
weptim profile image
WEPUKHULU TIMOTHY

Lol

Collapse
 
gistkitmedia profile image
GistKit.com

i have successfully applied this tutorial on my blog, gistkit.com.ng

Thanks for the helpful tutorial.

Collapse
 
jamessimel profile image
Simel James

thanks for this

Collapse
 
webdesigncheshire profile image
David Proctor

I think using gradients like this can really cheer up a bad image.