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 card solution using Flexbox and CSS variables

anna 340

@annab6

Desktop design screenshot for the Order summary component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


I feel like my code is not very "clean" and optimized. What could I do better? I also had difficulties centering the card vertically (I´ve done it with margin, but must exist better ways)

Community feedback

spyder 315

@ratan17

Posted

I see that you've used flexbox to center the card container which is a right approach. Your flexbox is only horizontally centered but not vertically. That's because you have to set height to the flex container which is your body element and then use another flexbox property align-items: center. This will center your card container both horizontally and vertically.

It would look like this:

body{
    min-height: 100vh;
      display: flex;
      justify-content: center;
   align-items: center;
} 

use min-height instead of just height.

If you want to get a good grip on flexbox I would suggest you to play this game: Flexbox Zombies Game

Marked as helpful

1

anna 340

@annab6

Posted

@ratan17 Thank you sooo much for a hint about container height. I´ve updated my code already, took out margins and the card is perfectly centered! I Will check the zombies game, thanks for the tip!

0
bunee 2,020

@buneeIsSlo

Posted

Hey! @Anna60991, Great job on this challenge. The page responds pretty well and your code looks good too. Centering elements does get a bit tedious sometimes, I struggle with it too.

I suggest taking This free course by Kevin Powell. In this course he covers some really important topics which should help you gain a better understanding of responsive layouts. Hope this helps :)

Marked as helpful

1

anna 340

@annab6

Posted

@buneeIsSlo Thanks for the feedback and a tip about the course! I´ve checked it out already, seems useful, I will definitely do it!

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