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

display : flex; margin: 210px auto 210px auto;

Axraxa 50

@axraxa

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


i found dificult to center the div , because it is easy to center it from sides of browser window , but i could not center it vertically . Did display: flex ; on body and then justify-content: center ; align-items: center; it didn't work , everything i tried didn't work so i had to use margin with exact pixels :( sadly.

Community feedback

@djbedford

Posted

Hey, you said you had trouble centering the div vertically, you're on the right track using flexbox with justify content and align items but you must also remember to set the height. The reason for this is because a div just takes up as much space as the content inside of it does, so when trying to center it vertically it has no room to move, in order to align it vertically you can set the height to 100vh which will give it the room to center it. Ideally you would wrap the div within a main tag and add the flex box and height styles there, this should solve your issue with vertically centering. You can also remove the top and bottom margin as they will no longer be required.

Apart from that good job!

Marked as helpful

3

Axraxa 50

@axraxa

Posted

@djbedford Thx a lot for your helpful explanation <3

0
Eugene 100

@SleepySleepyFox

Posted

You might try to center a div with: position: absolute; transform: translate(50%, -50%); right: 50%; top: 50%;

Marked as helpful

0

Axraxa 50

@axraxa

Posted

@SleepySleepyFox that's a nice way to solve it , but i started html and css 2weeks ago and didn't go that deep yet , have not checked transform element . thx for your time and information <3

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