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 challenge Using CSS Flexbox

#accessibility
David Gichuru• 360

@dxiDavid

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


How accurate was I compared to the design? Is there any issue you see with the way I used flexbox?

Community feedback

Hassia Issah• 50,830

@Hassiai

Posted

Replace<div class="card-container">with the main tag, <div class="descriptive-title"> with <h1>, <div class="title"> with <p> and <div class="attribution"> with the footer tag to fix the accessibility issues. click here for more on web-accessibility and semantic html

To center .card-container on the page, add min-height:100vh; display: flex; align-items: center: justify-content: center; or min-height:100vh; display: grid place-items: center to the body.

To center .card-container on the page using flexbox:
body{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
To center .card-container on the page using grid:
body{
min-height: 100vh;
display: grid;
place-items: center;
}

Use relative units like rem or em as unit for the padding, margin, width values and preferably rem for the font-size values, instead of using px which is an absolute unit. For more on CSS units Click here

Hope am helpful.

Well done for completing this challenge. HAPPY CODING

Marked as helpful

0

David Gichuru• 360

@dxiDavid

Posted

@Hassiai Thank you, I really struggled to position the card

0
Hesam• 420

@hesam-fattahi

Posted

Hey there!👋 Good job on finishing the challenge .

Here are some tips to improve your code:

  • Your component should be wrapped with main element.

  • And for other elements like headings and paragraphs, there is no need to wrap them around div.

  • You can use picture and source for you image, which doesn't need a media query in CSS for changing images. More info on MDN.

  • For accessibility reasons, the img alt text shouldn't be empty. It should describe the image.

  • You might wanna add to the media query's viewport since there are many phones with viewports larger than 375px, therefore the flex-direction doesn't change to column and the component won't look good on phones with bigger screens.

If you need further clarification l, I would be happy to help.

Happy coding :)

Marked as helpful

0

David Gichuru• 360

@dxiDavid

Posted

@hesamf01 Thanks, that's some prety usefull feedback

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