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 using only CSS with Flexbox

P
Karol 210

@CharlesSquirel

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


Hey, it was my first more professional project ever. I used first time media queries, so i am unsure of that. Another problem was with centering all in flexbox. Should I start to use Bootstrap or stay in pure CSS for the time being? Feedback welcome. Thanks for your comments.

Community feedback

Lucas 👾 104,420

@correlucas

Posted

👾Hello @CharlesSquirel, Congratulations on completing this challenge!

Your solution its almost done and I’ve some tips to help you to improve it:

1.Your component is perfect, but is not responsive yet, this is due the fixed width you've applied to the container.Look both width and max-width the main difference between these properties is that the first(width) is fixed and the second(max-width) is flexible, for example, a component with width: 800px will not grow or shrink because the size will be ever the same, but a container with max-width: 800px or min-width: 800px can grow or contract depending of the property you've set for the container. So if you want a responsive block element, never use width choose or min-width or max-width.

2.A better way to work this solution image, the product image is by using <picture> to wrap it on the html instead of using it as <img> or background-image (with the css). Using <picture> you wrap both images (desktop and mobile) and have more control over it, since you can set in the html when the images changes setting the screen size for each image.ote that for SEO / search engine reasons isn’t a better practice import this product image with CSS since this will make it harder to the image.

Here’s the documentation and the guide to use this tag: https://www.w3schools.com/tags/tag_picture.asp

See the example below:

<picture>
  <source media="(max-width:650px)" srcset="./images/image-product-mobile.jpg">
  <img src="./images/image-product-desktop.jpg" alt="Gabrielle Parfum" style="width:auto;">
</picture>

3.Use <main> instead of a simple <div> this way you improve the semantics and accessibility showing which is the main block of content on this page. Remember that every page should have a <main> block and that <div> doesn't have any semantic meaning.

✌️ I hope this helps you and happy coding!

Marked as helpful

0

P
Karol 210

@CharlesSquirel

Posted

@correlucas Thank you for your advices. They are very helpful :)

1
Divine Obeten 2,415

@Deevyn9

Posted

Hi Karol, congrats on completing this project, seeing that is is you’re first solution here makes it even better, because everything turned out perfect. Congrats again.

Happy coding 🎈

1

P
Karol 210

@CharlesSquirel

Posted

@Deevyn9 Thank you :)

1

@Nondaba

Posted

@CharlesSquirel ,congrangrats on finishing the project. My question is how did you manage to change the layout of desktop to mobile as so in design images using media query?

0
P
Karol 210

@CharlesSquirel

Posted

@Nondaba I checked what's the different between desktop layout and mobile layout and put changes inside media query.

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