Design comparison
Solution retrospective
Hi, everybody This is my solution for Product-preview-card-component. Just take a look at my code if you can give any feedback. I've checked the code with 3wc validators.
I have a question about browsers behaviors, there are different for the resizing of the image:
line 16
<img srcset="./images/image-product-mobile.jpg 686w,
./images/image-product-desktop.jpg 600w"
sizes="(max-width: 800px) 686px,
600px"
src="./images/image-product-mobile.jpg"
alt="photo perfume">
When I use firefox, I shrink and after grow the page, with firefox the image switch correctly between the both size.
and with Chrome and edge, the image is the good one before resizing, when I shrink and after I grow the page, the image don't switch and stay for the mobile size.
Do you have any idea? Thank you all.
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.
POINTING CURSOR ↗️:
- Looks like the component's
button
element has not a pointer, this property plays a major-role in terms of both UI & UX
- The
cursor: pointer
CSS property is important for button-like elements because it changes the cursor from the default arrow to a pointer when hovering over the element. This provides a visual cue to the user that the element is clickable and encourages interaction.
- In terms of UI/UX, using
cursor: pointer
helps to improve the usability of the interface by making it easier for users to identify interactive elements. It also helps to provide feedback to the user by indicating which elements are clickable and which are not.
- So we want to add this property to the following
button
element
button { cursor: pointer; }
- Now your component's
button
has got the pointer & you learned about this property as well
.
I hope you find this helpful 😄 Above all, the solution you submitted is great !
Happy coding!
Marked as helpful0@Lo-DeckPosted over 1 year ago@0xAbdulKhalid Thank you, I've tried and this is better when you use the website.
0 - @lack21Posted over 1 year ago
Excellent work 👍, but I have a suggestion!
- Add
object-fit: cover
to theimg
, it will center it!
Marked as helpful0 - Add
- @mukwende2000Posted over 1 year ago
Go and search for html picture tag and use that in your code. It will work, that is the best way to render different elements for different conditions.
Marked as helpful0@Lo-DeckPosted over 1 year ago@mukwende2000 Thank you for your comment, I've used the
<picture>
tag and it's better.0 - @Jahan-ShahPosted over 1 year ago
Hi 👋. Weldone for solving the solution. I'm here to answer your question. I hope you'll find this helpful
I can see that you are trying to change the image inside HTML only. You can do that by using the following steps, I will also attach a code snippet for you:
- First write a
<picture>
tag. - Inside that picture tag write two tags
<source/>
and then the<img/>
tag (both of which are self-closing tags). - In the
<source/>
tag you'll use two HTML attributessrcset
which will be the destination path to the image, andmedia
which will be basically used for media query, where you will define when you want this source image to be used. Like in my code, it's after 600px. - Now in the
<img/>
tag you'll set the src to another image and alt tag for better accessibility.
<picture class="product__img"> <source srcset="./images/image-product-desktop.jpg" media="(min-width: 600px)" /> <img src="./images/image-product-mobile.jpg" alt="Gabrielle Essence Eau De Parfum bottle" /> </picture>
I hope this might help you achieve your results. 😄
0@Lo-DeckPosted over 1 year ago@Jahan-Shah thank you, I've changed my solution with the tag
<picture>
, and now it's working perfectly.0 - First write a
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