Design comparison
SolutionDesign
Solution retrospective
What are you most proud of, and what would you do differently next time?
I am proud of getting the design right. Next time I will try to finish the project sooner and set a time limit.
What challenges did you encounter, and how did you overcome them?The spacing and sizing of elements was a little tricky, after trying many time I was able to match the design
What specific areas of your project would you like help with?How to make the image responsive that they change according to sizing of the device?
Community feedback
- @huyphan2210Posted 17 days ago
Hi, @arsh-de
I checked out your solution, and I also saw your question. Here's my attempt to answer it:
- Responsive Background Image: Currently, you’re using
background: url(images/image-header-mobile.jpg) no-repeat center/cover
on.img-container
, which setsbackground-size: cover
. To make the image responsive based on the viewport width, trybackground-size: 100vw
instead. This makes the image’s width equivalent to the viewport width. You can adjust100
to achieve the exact size you want. - Container Responsiveness: You might notice that setting
background-size
to100vw
makes the image responsive to the viewport but not to its container (.img-container
). This can sometimes lead to unintended results. A more flexible approach is to keep the image as a background on.img-container
(as you have it) and focus on making.img-container
responsive instead. Since.container
(its parent) hasmax-width: 900px
, adjusting this value can help make.img-container
more responsive. - Using an
<img>
Tag: Alternatively, using an<img>
tag instead ofbackground-image
can simplify things, allowing you to set itswidth
andheight
directly with viewport units if needed. This approach can make it easier to control responsiveness.
Hope this helps!
Marked as helpful1@arsh-dePosted 16 days ago@huyphan2210 Thank you for review, I will try this in my future projects. Regards1
1 - Responsive Background Image: Currently, you’re using
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