Stats preview card component with HTML and CSS
Design comparison
Solution retrospective
Hi! feedback would be highly appreciated. Especially about the image. I tried using an img tag but could't make it behave like a background img with css. In particular, the image wouldn't grow with the container and there would be a gap at the bottom. Thank you!
Community feedback
- @vanzasetiaPosted over 3 years ago
👋Hi Javi Rodriguez! My name is Vanza!
I have a solution for the image problem and this was also what I did when trying to complete this challenge:
- I recommend to create an empty
div
inside thearticle
- Then try to use these properties on the
div
:
article div { background: url('./images/image-header-mobile.jpg') no-repeat center center; background-color: var(--soft-violet); background-blend-mode: multiply; background-size: cover; height: 13.125rem; // => 210px / 16 }
That's it! Hopefully this is helpful!
Marked as helpful0@JaviRdrgzPosted over 3 years ago@vanzasetia Hi Vanza! thank you for replying. Your solution looks very similar to mine, did you use an <img> tag in the HTML or just the div with the background?
0@vanzasetiaPosted over 3 years ago@JaviRdrgz Sorry, the code that I wrote above, was not exactly what I did when I created this solution as far as the HTML. I was seeing your code and then I gave a solution for you, based on your code.
So, I used
section
tag, but you can usediv
, then give it abackground-image
on CSS.If you're confused on how to do it, you can check my solution on this challenge or you can just ask me right here.
That's it! Hopefully this answer your question!
0 - I recommend to create an empty
- @akash-1712Posted over 3 years ago
Give min-height:20rem to picture and add some Margin-top:10rem in article for mobile Layout.
To turn the image purple make a (div.image) give background-color:purple and then put image inside it with property=>{opacity:0.3}.
Marked as helpful0@JaviRdrgzPosted over 3 years ago@akash-1712 Oh I get it, so the solution would be to give the <img> tag a default height so that it is the biggest element in the component. Thank you for your feedback Akash!
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