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

Responsive Product preview card component page using HTML and CSS

@R4f0so

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. Is my code too long?
  2. Have I wrote a code following the best practices? What can I improve?
  3. Is the responsiveness well made?
  4. In terms of skills of both CSS and HTML, what can I improve?
  5. To do the responsiveness I got to use the flex-wrap property in order to move my image to the top. Are any other ways to do this?

Community feedback

Pon Huang 210

@ponhuang

Posted

Hello Rafael

You’re doing quite well on the project. 😃

There are few parts would suggest change, and it would improve the code.

1.) In order to set the image border-radius in each angle, it will be better to set overflow: hidden; to the parent container.
 Then you won't need to do it every single time, the border keeps the radius.


preview-card{
overflow: hidden;  // add this line
}

content-img{
Border-radius: 10px 0 0 10px; // delete this line
Background-size: cover; // this could complete show the whole image without setting any specific unit
}

2.) The other is the cart icon didn’t show up in the button. That is cause the src you add one **/ ** before images, delete this / and it can work.

 Also, give specific width and height to the icon.

<img src="images/icon-cart.svg">

3.) If you only want to have an empty container to set image in CSS, then better use <div> instead of <img> element.

When use empty <div> for image, we can set role=“img” and aria-label=“(brief description of the image)”.

<div class=“img” role=“img” aria-label=“perfume picture”>




Hope this help :)
 Have a nice day

Marked as helpful

0

@alimuddinhasan

Posted

  • I don't think your code is too long, but I suggest ensuring your indentation is correct. It looks like a simple thing, but believe me, it helps a lot for code readability. If you use vscode, try prettier extension
  • Your project structure is a bit unusual. It works but does not follow the best practice. For instance, you should put the CSS files in the style folder instead of the src

Marked as helpful

0
faizan 2,420

@afaiz-space

Posted

Hey @R4f0so, add align-items: center; in price-container class. also remove margin-top: 10px; from .previous-price class

Marked as helpful

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