@dxiDavid
Posted
Hello @WiaterKa ๐๐พ
Congrats on completing the challenge.
To solve your centering problem, try wrapping everything in a wrapper div or main container and center it using flexbox or grid.
body {
background-color: hsl(210, 46%, 95%);
margin: auto;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
width: 1100px;
height: 572px;
}
For the above code you've written, declare a min-height
first then use flexbox. Please do not give the body a fixed height or width after. The auto margin is also unnecessary.
One last thing, avoid using pixels for dimensions, font sizes, or spacing. You're better off using em
or rem
.
I hope you found this helpful, happy coding๐ฅ
Marked as helpful
@WiaterKa
Posted
@dxiDavid thank you for the suggestions!
If you be so kind and explain why shouldn't I give the body a fixed height or width after and what's the meaning for the order of listing properties for a given (one) class I would be grateful :)
The above paragraph refers to this part of your comment:
"For the above code you've written, declare a min-height first then use flexbox. Please do not give the body a fixed height or width after. The auto margin is also unnecessary."
Have a nice day!
@dxiDavid
Posted
@WiaterKa By fixed height and width I mean declaring height
and width
instead of max-height
and max-width
.
- setting fixed dimensions on elements means that they will always be that size no matter the width and height of the viewport (device).
- This makes your website unresponsive and will most likely lead to writing a bunch of media queries which is something you don't really want to do.
If you set a max-width
and max-height
then it will shrink with the viewport and only grow to the largest size set. An element with fixed absolute dimensions does not shrink it remains as is and may cause overflow.
You can get away with declaring width
for small elements like social media icons but still wouldn't recommend that you it.
I hope you understand what I mean now.
Marked as helpful
@WiaterKa
Posted
@dxiDavid thanks, all clear now! :)