Design comparison
Solution retrospective
This challenge was similar to the previous one, it is a confirmation of the skills for me. Let me know if you see something that need improvement.
Thank you
Community feedback
- @0xabdulkhaliqPosted over 1 year ago
Hello there 👋. Congratulations on successfully completing the challenge! 🎉
- I have other recommendations regarding your code that I believe will be of great interest to you.
PiCTURE TAG 📸:
- Looks like you're currently using media queries for swapping different version of
image
by enabling and disabling them, So let me introduce thepicture
element which may help you to handle all these stuffs without any hassle.
- The
<picture>
tag is commonly used for responsive images, where different image sources are provided for different screen sizes and devices, and for art direction, where different images are used for different contexts or layouts.
- Example:
<picture> <source media="(max-width: 768px)" srcset="small-image.jpg"> <source media="(min-width: 769px)" srcset="large-image.jpg"> <img src="fallback-image.jpg" alt="Example image"> </picture>
- In this example, the
<picture>
tag contains three child elements: two<source>
elements and an<img>
element. The<source>
elements specifies different image sources and the conditions under which they should be used.
- Using this approach allows you to provide different images for different screen sizes without relying on CSS, and it also helps to improve page load times by reducing the size of the images that are served to the user
- If you have any questions or need further clarification, you can always check out
my submission
and/or feel free to reach out to me.
.
I hope you find this helpful 😄 Above all, the solution you submitted is great !
Happy coding!
Marked as helpful0@Gwen-legoPosted over 1 year agohi @0xAbdulKhalid,
Thank you for this introduction of the Picture element. I have applied it and it works :).
0 - @graynnejiPosted over 1 year ago
Very Clean Design but I will give you a solution that will help make your gird responsive without media query
.wrapper { background: white; border-radius: 0.5em; display: grid; grid-template-columns: repeat(auto-fit, minmax(37em, 1fr)); }
Grid columns break after hitting 37em of width
Marked as helpful0@Gwen-legoPosted over 1 year agoHi @graynneji,
Thank you for taking the time to comment, I implemented your advice it to my coding. I have to keep the max-width of the container otherwise it gets bigger and adjusted the min to 18.3 (roughly half of the max-width, one column) as I have two columns. Now grid columns break after one column hits 18.3em.
Thanks a lot, let me know if you see something else.
.wrapper { max-width: 37em; background: white; border-radius: 0.5em; display: grid; grid-template-columns: repeat(auto-fit, minmax(18.3em, 1fr)); overflow: hidden;
0 - @graynnejiPosted over 1 year ago
You are almost there... Remove this max-width: 37em; from the wrapper class in your CSS and also remove media="(max-width: 33em) from your source tag in your HTML. Now when you load the page and reduce the size of your browser to like phone size. you will see the responsiveness it will be only one column. I have done it here and it works fine. try it out and let me know the result.
0@Gwen-legoPosted over 1 year agoIt makes sense to remove the max-width form the wrapper class If I remove the media="(max-width: 33em) the image does not change , the mobile one stays on. I left it on... did it work for you?
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