+ 1
Centerring
Hi guys why i can not centerring the lol div in vertical axes ? body{ padding: 0; margin: 0; display: flex; justify-content: center; align-items:center; text-align: center; } .lol{ width: 100px; height: 100px; background: black; }
2 Answers
+ 2
From trying your code, it seems that your "lol" element is centred horizontally, but not vertically, which is what you want I assume.
That's because by default, the <body> element has a height of 0. Therefore the centre vertically is also at 0. To fix this, add this to the body section of the CSS code:
" height:100vh;"
,which basically means the body element takes up 100% of the height of the window.
0
Thank you i will try it