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 with flex-box

Asumpta-1 30

@Asumpta-1

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


i havent managed to make the page responsive , any help would be appreciated

Community feedback

@ahmedafsa

Posted

Hello @Asumpta-1, great work!

Here are some notes for improving the code:

  • CSS Grid is best for the two-dimensional layouts with many elements that need to be precisely positioned relative to each other, while Flexbox is better for one-dimensional or single-line layouts where you just need to space a bunch of elements a certain way. So in case of the card in the challenge, it's better to use CSS Grid like the following
.your-container-div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 600px;
}

This will align the product image next to the details directly, making the code better and easier and It will also help us in making the component responsive by converting the layout from two columns to one column through media query, like this:

@media(max-width:600px) {
  .your-container-div {
    grid-template-columns: 1fr;
  }
}
  • Regarding the product image It is better to use the <picture> element with <source> tags to make the product image responsive where based on your screen width, the appropriate image will be loaded instead of the two <img> elements.
<picture>
  <source
    srcset="images/image-product-mobile.jpg"
    media="(max-width: 600px)"
  />
  <source
    srcset="images/image-product-desktop.jpg"
    media="(min-width: 601px)"
  />
  <img src="images/image-product-desktop.jpg"/>
</picture>

Best wishes to you!

Marked as helpful

0

Asumpta-1 30

@Asumpta-1

Posted

Hi @ahmedafsa , Thank you for your detailed solution, very much appreciated. I will implement this asap and learn css grid better. 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