Design comparison
Solution retrospective
In this challenge I incorporated some accessibility tips I got from my first challenge, and I tried using Flexbox this time.
I had some trouble when the media query was called for the desktop version. The main container turns from flex-direction column to row on the query, being it's two items the product-photo section and the product-info section but the product photo section displayed a bottom space that I didn't know what it was. The product info section occupied the 100% of the heigth, no problem with that, it was only the one on the left. I tried some things and what worked for me was to set nothing for the product photo width in the media query and set the img width to the exact px amount of the main width. What doesn't make sense to me is that the product-photo section retains the 100% width from mobile, buy when tried to set it to 50% of the main width or the exact px width of main for desktop it didn't work, had to leave it at 100% and only change the img width.
Community feedback
- @CarlHummPosted over 1 year ago
Hello
- When you set width 100% on image large it takes up all the room of its parent container #product-photo.
- #product-photo has very little room and appears squished compared to product-info which has a greater width.
- There is not enough width for image large to scale, it cannot fill the empty space without distorting its aspect ratio so leaves a gap.
- If you change both the product-photo and the product-info container's width to 50%, or flex: 1, then the image will fit.
If the content of product-info changes, or you add additional padding then the main element could once again grow in height, and show a gap below the image. If you want the image to fill the space, and don't mind it being partially clipped, you can use the property
object-fit: cover
and setheight:100%
.You can read more about this property here
Marked as helpful0
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