I’m having trouble understanding why the align-items: center; property didn’t work in my code. Could someone kindly help me to understand why it didn’t work? TIA!
My code:
html {
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
font-family: 'Roboto', sans-serif;
font-weight: bold;
height: 100%;
}
#registration-page {
height: 100%;
background: #78a7ba;
display: flex;
justify-content: center;
align-items: center;
overflow: scroll;
}
<body>
<section id="registration-page">
<form class="signup-form">
Registration Form
</form>
</section>
</body>
2
Answers
If you are trying to center the text vertically
height: '100%'
isn’t enough because it simply takes the full size of the content.If you want the full screen change it to
height: '100vh'
You are missing the
body
element betweenhtml
and your element. It’s not the full screen size so your elements100%
are not taking the full screen.This is how you could fix it:
OR