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 CSS

Aaron Li 90

@aaronli722

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


After the project, I have two questions:

  1. How to vertically center a span element?

  2. Is it possible to set the height of a div same as the background image? (which mean can fully show the background image with correct scale)

Community feedback

P
Larra 10

@larrasu

Posted

Hello! Your solution looks excellent overall!

A few things you might want to add are the rounded corners of the card component and add overflow: hidden so the image molds into the rounded corners.

To answer your questions:

  1. You can vertically center a span element by adding Flexbox to the parent element like this:
display: flex;
items-align: center;
  1. Yes, it is possible to set the height of the div the same as the background image by adding background-size: cover to your div. If you are using an img element, you can also do it by adding object-fit: cover to your img element.

I hope this helps! Happy coding ✨

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