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

Perfume product card

BDWNAV 50

@BDWNAV

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


What are you most proud of, and what would you do differently next time?

I am proud of my flexbox usage as I feel like I used it effectively.

What challenges did you encounter, and how did you overcome them?

Some challenges I encountered were positioning and I implemented certain flexbox properties to overcome this issue.

What specific areas of your project would you like help with?

I would like to see if I am using flexbox correctly and also efficiently.

Community feedback

P
Douo 940

@Douoo

Posted

Hi BDWNAV, good job putting this together! 😊 I got a few suggestions for you here:

  1. I would suggest wrapping the main-div inside the <main>...</main tag as this will semantically helps the code refer main content of the body.
  2. Right now the component in the mobile have a stretched image with height that fills in the screen. This could restrict the flexibility of the component and one fix would be to wrap your card into a container class like as follow:
.container{
width: min(80%, 600px); 
/*This will give the card a max width of 600px but will give the elements in it 80% maximum width of the screen (if its below 600px) */
margin-inline: auto; /*Centers the element */
}
.main-div{
min-height: 450px;
padding: 1rem;
/*Now you can remove the width constraint here and the 100% height & width property within the mobile view */ 
}

Then in html

<main class="container">
   <div class="main-div">...</div>
</main>
  1. Instead of using the <image/> tag with CSS for handling the switching of the desktop and mobile images, try to use the picture element instead since this is a product image and is thus central to the card.
<picture>
   <source media="(max-width: 375px)" srcset="images/image-product-desktop.jpg" />
   <img src="images/image-product-mobile.jpg" alt="Glass perfume bottle placed against a leafy background" />
</picture>

Hope some of this can help you out, and really great work on the whole, so keep going!

0

BDWNAV 50

@BDWNAV

Posted

@Douoo thanks for the help what do you mean by the image stretches out on mobile?

0
P
Douo 940

@Douoo

Posted

@BDWNAV Here is a screenshot: Screenshot You can see that the image is stretched (making a bit disoriented in its dimension). Perhaps you could use object-fit property to fix this with your current styling

.mobile-product-image{
...
object-fit:cover;
} 

I prefer you use the <picture> tag though. More details here Picture tag

0
BDWNAV 50

@BDWNAV

Posted

@Douoo oh I didn't even notice that it wasn't like that for me on mobile at all! Thanks for the help

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