Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Vanilla HTML and CSS; Flexbox; Media query;

@fabiofigrod

Desktop design screenshot for the Stats preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


What is the best way to apply the color overlay effect to the image?

Community feedback

Yudi Yoshida• 350

@yudiyoshida

Posted

You can also apply an overlay this way:

HTML:
<div class="container-with-background-img">
   <div class="overlay"></div>
   ...
</div>

CSS:
.container-with-background-img {
   background-image: url("...");
   position: relative;
}
 
.overlay {
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   background-color: black;
   opacity: 0.6;
}
0

Yudi Yoshida• 350

@yudiyoshida

Posted

And if you want to add more content inside parent div, you need to make them relative as well.

0
Gonza Zabaleta• 155

@gonzabaleta

Posted

Just wanted to say that your code is so clean. I learned a lot with it :)

0

@matheus-rodrigues00

Posted

Hi Fabio! I mean... it works well :) Another way to achieve a similar effect would be to set the image in background-image, add the violet in background-color and use the background-blend-mode property. Not saying that this would be better but it's good to be aware of options!

Hope this helps :)

0

@fabiofigrod

Posted

@Rafok777 Thanks! It is a very nice option and I didn't knew about it! Looks like more professional and have a lot more options than putting some pseudo element to play around with the opacity!

0
P
Patrick• 14,325

@palgramming

Posted

🌟🌟🌟🌟🌟 Looks good

maybe this will help you with the overly color https://highrise.digital/blog/css-blend-modes/

0

@fabiofigrod

Posted

@palgramming Thank you for sharing this article! It helped a lot and looks like a much more professional solution!

1
P
Patrick• 14,325

@palgramming

Posted

@fabiofigrod No problem glad it helped

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord