center a div in css
.container {
display: flex;
justify-content: center;
align-items: center;
}
center a div in css
.container {
display: flex;
justify-content: center;
align-items: center;
}
css center everything
/* to make "align-items: center" work: use "min-height: 100vh;"
100vh = 100% Viewport Height */
body {
display: flex;
min-height: 100vh;
flex-direction: column;
justify-content: center;
align-items: center;
}
html css center text on page
<style>
body { background: white }
section {
background: black;
color: white;
border-radius: 1em;
padding: 1em;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%)
}
</style>
<section>
<h1>Nicely centered</h1>
<p>This text block is vertically centered.
<p>Horizontally, too, if the window is wide enough.
</section>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us