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 using flexbox

Godsfavour03ā€¢ 20

@Godsfavour03

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Community feedback

Izzat Razabā€¢ 70

@izzatrazab

Posted

Nice work on completing the challenge. šŸ‘

I have some suggestions on your code that may help you.

  • Set height of html and body to 100%, why ? this will make centering any contents much easier and will avoid extra white space at the bottom of the page or when zooming (though this does not happens in your case). To do that:
html{
height: 100%;āœ…
}
body {
min-height: 100%;āœ…
background-color: hsl(30, 38%, 92%);
}
  • To center the card: Instead of using margin which is not responsive and akward, I would suggest using display:flex;. Now that we already set height of html and body element to 100% before, there will be no awkward slightly offset position because they are covering you viewport 100% (in desktop view, your card is a little bit off to the top):
body {
min-height: 100%;
display: flex;āœ…
justify-content: center;āœ…
align-items: center;āœ…
background-color: hsl(30, 38%, 92%);
}
.pricecard { 
width: 90%;
/* margin: 2em auto 2em auto; */āŒ
background-color:  hsl(0, 0%, 100%);
border-radius: 20px;
max-width: 600px;
}
@media (min-width:600px) {
.pricecard {
display: flex;
max-width: 500px;
/* margin-top: 10em; */āŒ
}
  • Landmark main element: I see that you did not use main element. This is actually bad practice as using landmark helps screen reader users easily navigate your website. But why? Look here briefly: HTML5 landmark elements are used to improve navigation. Try evaluate your deployed website here. Though you don't have to stress out too much on this because it will make sense to you the more you practice. I would do this instead:
<main class="pricecard">āœ…
<div class="pricecard">āŒ
...
</div>āŒ
</main>āœ…

I downloaded your code and tried all the above locally and it works fine. If you found this helpfull, please upvote this comment as it will help me improve. That's all from me, adios.

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