Design comparison
Solution retrospective
This project was actually more tasking that I thought it to be.I was able to complete it and I'm proudπ.
- This is the first Project I'm doing on my own on responsive designs(asides following tutorials).
- I was able to switch the two images for mobile and for desktop
- I was able to vertically align my work which was a real hassle for me before.
CHALLENGE I was faced with the challenge of switching between the mobile image and the desktop image. SOLUTION I placed my image in a div and then gave the div an ID of "my-image" and a class of "product-image". At the breakpoint I then changed the image using 'the background-image' property on the class and set the visibility of "my-image to hidden".
#my-image{
visibility: hidden;
}
.product-img{
border-radius: 15px 0 0 15px;
background-image: url("images/image-product-desktop.jpg");
background-size: cover;
}
Pls recommendations on a better way to do this.
What specific areas of your project would you like help with?I'd be really open to responses on these
- How to improve typography in responsive designs.
- better ways to switch between the images for mobile and desktop
- How to improve on my code , because I feel it was not clean enough.
Community feedback
- @MatthewPCopePosted 5 months ago
Thanks for the info @VCarames, I'll check out that picture element!
0 - @MatthewPCopePosted 5 months ago
Hey, great job! As far as switching between images...this is what I did...instead of putting the first image in the html I made an empty div with a class of .images and then did the background-size:cover and background-image: url("") in the css. Then in the media query I did the same thing but switched the url of the image. Hope that helps!
0@VCaramesPosted 5 months ago@MatthewPCope @Mineshaye
Unfortunately, this is not the correct way to accomplish this task.
For situations where different images are needed at different breakpoints, the
picture
element is ideal, as it is specifically designed for this purpose.<picture> <source srcset="Different IMG" media="(min-width: px)" /> <img src="default IMG" alt="" /> </picture>
More Info:
0@MineshayePosted 5 months agoWoah how did I not think of that. Thanks so much @MatthewPCope
0@MineshayePosted 5 months agoThanks so much @VCarames , I'm just seeing this for the first time.
1
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