+ 1

Flex vertical align not working

Why does the align-items: center in flex not work? I've used justify-content, flex-direction, align-items, display:flex and even set the button as a flex item. It won't center vertically. https://code.sololearn.com/WTkLeDeOBQBe/?ref=app

3rd Jul 2020, 8:58 AM
Clueless Coder
Clueless Coder - avatar
7 Respuestas
+ 3
set the body height first, you'll see the difference
3rd Jul 2020, 9:00 AM
Taste
Taste - avatar
+ 4
Taste ~♥~YO YO ~♥~ I wish I could set both of you as best answers. Thanks for the tip, weird how no one's mentioned that to me before.
3rd Jul 2020, 9:05 AM
Clueless Coder
Clueless Coder - avatar
+ 4
Use html, body { height: 100% }
3rd Jul 2020, 9:33 AM
Calviղ
Calviղ - avatar
3rd Jul 2020, 9:53 AM
Calviղ
Calviղ - avatar
+ 2
Thanks Calviղ , I set it as height: 100vh;
3rd Jul 2020, 9:41 AM
Clueless Coder
Clueless Coder - avatar
+ 2
Calviղ Thanks. I honestly thoughts they same
3rd Jul 2020, 10:23 AM
Clueless Coder
Clueless Coder - avatar
+ 2
Clueless Coder I use unit % rather than vh, vw whenever possible. It should be better practice, it's more versatile for building component for container, rather than constraint by the fixed dimension.
3rd Jul 2020, 10:58 AM
Calviղ
Calviղ - avatar