Product preview card component challenge Using CSS Flexbox
Design comparison
Solution retrospective
How accurate was I compared to the design? Is there any issue you see with the way I used flexbox?
Community feedback
- @HassiaiPosted almost 2 years ago
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 helpful0@dxiDavidPosted almost 2 years ago@Hassiai Thank you, I really struggled to position the card
0 - @hesam-fattahiPosted almost 2 years ago
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
andsource
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 helpful0@dxiDavidPosted almost 2 years ago@hesamf01 Thanks, that's some prety usefull feedback
1 -
Please log in to post a comment
Log in with GitHubJoin 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