Responsive Stats Preview Card using pure CSS
Design comparison
Community feedback
- @correlucasPosted about 2 years ago
πΎHello Shiva, congratulations for your new solution!
Here's some tips to improve your photo:
To have your image purple with the same overlay effect, you need to use
mix-blend-mode
to make this color blend between the image and the background-color of the container. See the steps below to apply to theimg
orpicture
selector. And the best part is that you;ll have a code really more clean than the current code, see the difference":BEFORE:
.card__img::before { content: ""; inset: 0; position: absolute; background-color: var(--clr-primary-accent-light); opacity: 50%; }
AFTER
img { mix-blend-mode: multiply; opacity: 75%;}
Try to fix the image responsiveness
display: block
andmax-width: 100%
andobject-fit: cover
to make the image auto-crop when resizing inside the column:img { display: block; object-fit: cover; max-width: 100%; }
π I hope this helps you and happy coding!
0@shivaprakash-sudoPosted about 2 years ago@correlucas Hello, thank you for commenting on my solution. I've tried your code and it doesn't seem to have any effect on the output, especially the
object-fit
line. Themix-blend-mode
line makes the image too dark, same as the background, not the purple accent like in the design.0@correlucasPosted about 2 years ago@shivaprakash-sudo You need to use
opacity: 75%
to make the color blend with the background color of the layer, but if you need to use this effect with one element thats comes from the html as<img>
or<picture>
if is a pseudo-element orbackground-image
this effects doenst work properly.I applied these changes to my solution and you can check here how I did:
https://www.frontendmentor.io/solutions/stats-preview-card-vanilla-css-custom-design-text-animation-RfGBFlMpwK
0@shivaprakash-sudoPosted about 2 years ago@correlucas Tried that, but it didn't work. Also, your CSS file is minified and everything is in one line, so I'm not able to check your code properly.
0
Please log in to post a comment
Log in with GitHubJoin 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