1
I’m trying to create a simple page in HTML, resizable, where the content is all centered vertically.
But I’m not able to center the text boxes in any way.
This code will initially be the graphical interface of an Android APP. I am encoding so that the content automatically resizes according to the size of the Viewbox (Device).
I’m stuck on this centralizing part, and I can’t move forward.. I’m starting HTML5+CSS3 development and would like to ask for your help. Which direction should I take?
Follow the HTML code I’m using
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login</title>
<link href="css/login.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="divMain">
<div id="titleDiv">
<h1>LOGIN</h1>
</div>
<div id="loginDiv">
<input type="text" value="CPF/CNPJ" id="txtLogin"
onFocus="if (this.value=='CPF/CNPJ') this.value = '';"
onBlur="if (this.value=='') this.value='CPF/CNPJ';"/>
<input type="text" value="SENHA" id="txtPassword"
onFocus="if (this.value=='SENHA') this.value = ''; this.type='password';"
onBlur="if (this.value=='') {this.value='SENHA'; this.type='text';}"/>
</div>
</div>
</body>
</html>
And the code below in CSS:
html {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body {
background: #2F6790;
}
#divMain{
margin: auto;
width: 50%;
padding: 10px;
display:table;
}
#titleDiv{
justify-content: center;
align-items: center;
margin-top: 5%;
vertical-align:middle;
}
#txtLogin{
margin: auto;
width: 30%;
padding: 10px;
display:table-cell;
position:absolute;
}
#txtPassword{
margin: auto;
width: 30%;
padding: 10px;
display:table-cell;
position:absolute;
margin-top:5%;
}
#loginDiv{
justify-content: center;
align-items: center;
margin-top: 5%;
vertical-align:middle;
}
I am waiting. I thank you in advance!
Thank you so much! Your help was very important! Thanks!
– Herbert Lausmann