Как сделать содержимое блока по центру в CSS?
Есть сырая форма авторизации, как сделать ее содержимое в центре блока?
.header {
background-color: white;
color: black;
height: 90%;
margin: 5%;
border-radius: 10px;
text-align: center;
font-family: "Times New Roman", Georgia, Serif;
}
<div class="login">
<h3>LOG IN</h3>
<p>
<input name="mail" type="mail" />
</p>
<p>
<input name="password" type="password" />
</p>
<p>
<input name="button" type="button" />
</p>
</div>
Ответы (2 шт):
Автор решения: Arcadiy
→ Ссылка
.header {
background-color: white;
color: black;
height: 90%;
margin: 5%;
border-radius: 10px;
text-align: center;
font-family: "Times New Roman", Georgia, Serif;
}
p input{text-align:center;margin:0px auto; padding:0px;}
<div class="login">
<h3>LOG IN</h3>
<p>
<input name="mail" type="mail"/>
</p>
<p>
<input name="password" type="password"/>
</p>
<p>
<input name="button" type="button"/>
</p>
</div>
Автор решения: De.Minov
→ Ссылка
Воспользуйтесь Flexbox
body {background: #999}
.login {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: white;
color: black;
height: 200px;
margin: 5%;
border-radius: 10px;
text-align: center;
font-family: "Times New Roman", Georgia, Serif;
}
.login h3 {
margin-top: 0;
}
.login p {
margin: 0 0 10px;
}
<div class="login">
<h3>LOG IN</h3>
<p>
<input name="mail" type="mail" />
</p>
<p>
<input name="password" type="password" />
</p>
<p>
<input name="button" type="button" />
</p>
</div>