Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Product-preview-card-component

P
Lo-Deck 2,020

@Lo-Deck

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

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

@0xabdulkhaliq

Posted

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 helpful

0

P
Lo-Deck 2,020

@Lo-Deck

Posted

@0xAbdulKhalid Thank you, I've tried and this is better when you use the website.

0
Luka Glonti 3,440

@lack21

Posted

Excellent work 👍, but I have a suggestion!

  • Add object-fit: cover to the img, it will center it!

Marked as helpful

0

P
Lo-Deck 2,020

@Lo-Deck

Posted

@lack21 Thank you for your help.

0
Mukwende 1,370

@mukwende2000

Posted

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 helpful

0

P
Lo-Deck 2,020

@Lo-Deck

Posted

@mukwende2000 Thank you for your comment, I've used the <picture> tag and it's better.

0

@Jahan-Shah

Posted

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:

  1. First write a <picture> tag.
  2. Inside that picture tag write two tags <source/> and then the <img/> tag (both of which are self-closing tags).
  3. In the <source/> tag you'll use two HTML attributes srcset which will be the destination path to the image, and media 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.
  4. 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

P
Lo-Deck 2,020

@Lo-Deck

Posted

@Jahan-Shah thank you, I've changed my solution with the tag <picture>, and now it's working perfectly.

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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