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 Responsive Design

@Alfrey-Chan

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


  1. To have the image occupy 50% of the card on the desktop view, I set the image to max-width: 50%, is that ok to do?
  2. Is it ok to swap images on different screens by having two image tags, but set one to display:none and the other to display:block, and just swap it around with media queries? Are there better approaches?
  3. Is there a better method to put an icon beside the text of a button? I used two span elements and treated the button as a Flexbox. (Code below)
<button>
          <span><img src="images/icon-cart.svg"> </span>
          <span>Add to Cart</span>
</button>
button {
  padding: 1.25rem;
  background-color: hsl(158, 36%, 37%);
  color: white;
  border-radius: 15px;
  font-family: 'Montserrat', sans-serif;
  font-size: 1.25rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}
  1. If there are any other better approaches to anything I've implemented, please let me know.

Community feedback

@zoedarkweather

Posted

Hi! You can use the HTML picture element when you have images you need to swap depending on screen size. No need for media queries if you use picture. Also as far as I know max-width 50% is fine to do when you need to? However, I would try using the features of grid or flex box for something like that. With grid, for example, you can set your columns 1fr 1fr and they'll be 50%. Or with flex box you could do flex=1. Hope this helps.

2

@Alfrey-Chan

Posted

@zoedarkweather Thank you so much. Your feedback really helps!

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