Design comparison
Solution retrospective
Hi all,
This was my first time using media query and I struggled getting the perfume image to match the the solution image on the mobile view. In my github repository there is a screenshot of my mobile page view, you will notice that the perfume bottle is not centred. Can anyone tell me where I went wrong and how I can fix this? The perfume image is within in the .sub-container-1 (lines 126 - 130 on the sytles.css file).
Thanks
Shamir
Community feedback
- @miroslavdurinPosted over 2 years ago
Hello Shamir, congratulations on finishing this project, it looks great :)
First of all I think that page looks better if you put media query on 650px, I would do that first. Problem with the image is that in a mobile view, you are still using image from a desktop view. You can use
<picture>
tag to switch between different images, based on a screen size. I would suggest that you write in you HTML, instead ofdiv.sub-container-1
:<div class="sub-container-1"> <picture> <source media="(max-width:650px)" srcset="images/image-product-mobile.jpg"> <img src="images/image-product-desktop.jpg" srcset="images/image-product-desktop.jpg" alt="parfume"> </picture> </div>
If you don't like this way, you can also set image as a
.sub-container-1
background-image, then you can change background inside of your media query.I would also suggest that you don't set image
width
andheight
in absolute units, you can use%
instead ofpx
, especially since you've already put fixedwidth
andheight
on.sub-container-1
. This is what I mean:.sub-container-1 { width: 300px; height: 470px; } .sub-container-1 img { width: 100%; height: 100%; display: block; }
I would also remove all of
border-radius
properties, there is no reason to put them on 3 elements, you can put them on main container, like this:.flex-container { display: flex; border-radius: 10px; overflow: hidden; }
I hope I managed to help you just a little bit. Good luck and happy coding :)
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