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

Simple product card with flex

MartinCermanโ€ข 70

@MartinCerman

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


One of my first projects. I struggled with semantic tags and css classes so I'd appreciate a comment on that. Which tags are chosen correctly and which aren't? Thanks!

Community feedback

Boots ๐Ÿ˜บโ€ข 1,590

@adityaphasu

Posted

Hey there! Good job on completing the challenge๐Ÿ™Œ๐Ÿป

One thing you could improve is how you've used absolute positioning for the desktop image. You can use <picture> element for the images instead of absolutely positioning them like this:

<picture>
<source srcset="images/image-product-desktop.jpg" media="(min-width: 768px)">
<img src="images/image-product-mobile.jpg" alt="Product preview">
</picture>

Here the srcset is being used for the desktop image URL and the media attribute is being used as a media query as to when the desktop image should show up. Initially, the image will be mobile but as soon as it hits 748px the image will be switched up to a desktop one.

This will save you from writing all the unnecessary code to absolute position the images.

๐Ÿ“ฑ The <picture> element is great for responsiveness! Here you can read more about it!

I hope this will be helpful in your future projects ๐Ÿ™‚

Happy Coding!๐Ÿ•บ๐Ÿป

Marked as helpful

1

MartinCermanโ€ข 70

@MartinCerman

Posted

@adityaphasu Thank you for this comment. Yeah looks like <picture> is indeed a modern way of inserting responsive images, I'll definitely use it in future projects!

1
Carlos Alโ€ข 160

@crsaele

Posted

It looks good.

You should try putting your css styles in a different file so your code doesn't look as messy.

Fix your media query :)

Happy coding.

1

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