Sample Login Form
by r2creations24
HTML
<div class="body">
<div class = "center">
<div class="div_form">
<div class="app_img"></div>
<h1>Sample Form</h1>
<form method="GET">
<div class="input_group">
<input type="email" onchange="checkTextEmail(this)" name="email" required>
<label class="test_label_email" for="email">Email</label><br/>
</div>
<div class="input_group">
<input type="password" onchange="checkTextPass(this)" name="password" required>
<label class="test_label_pass" for="password">Password</label><br/>
</div>
<input type="submit" value="Submit Button">
</form>
</div>
</div>
</div>
CSS
.body {
color: whitesmoke;
background-color: #004e5c;
display: grid;
justify-content: center;
align-items: center;
text-align: center;
width: 100%;
height: 100%;
margin: 0;
padding: 15px 0;
}
.center {
margin: auto;
}
.app_img {
padding: 5px;
width: 150px;
height: 150px;
margin: auto;
background-image: url("https://shift2dev.com/wp-content/uploads/2024/12/icon.png");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.div_form {
padding: 30px;
background-image: url("https://shift2dev.com/wp-content/uploads/2025/04/background.png");
background-position: center; /* Center the image */
background-repeat: no-repeat; /* Do not repeat the image */
background-size: cover; /* Resize the background image to cover the entire container */
box-sizing: content-box;
box-shadow: 2px 2px 10px whitesmoke, -2px -2px 10px white;
border-radius: 15px;
}
.input_group {
padding: 30px;
position: relative;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
transition: background-color 5000s ease-in-out 0s, color 5000s ease-in-out 0s;
}
input {
padding: 15px;
border: none;
border-bottom: 2px solid #eee;
outline: none;
background: transparent;
color: white;
}
.label {
color: #afb2c9;
float: left;
margin-top: 20px;
}
.test_label_email, .test_label_pass {
position: absolute;
left: 40px;
top: 20px;
transition: 0.3s;
}
input:focus ~ label {
top: 0;
left: 0;
color:rgb(217, 219, 226);
}
input[type="submit"]{
border-radius: 25px;
margin-top: 20px;
padding: 15px;
width: 100%;
background-color: #DDE1FF;
color: black;
}
#test {
top: 0;
left: 0;
color:rgb(217, 219, 226);
}
JavaScript
function checkTextEmail(inputElement){
if(inputElement.value.length == 0){
document.getElementsByClassName("test_label_email")[0].id = "empty"
} else {
document.getElementsByClassName("test_label_email")[0].id = "test"
}
}
function checkTextPass(inputElement){
if(inputElement.value.length == 0){
document.getElementsByClassName("test_label_pass")[0].id = "empty"
} else {
document.getElementsByClassName("test_label_pass")[0].id = "test"
}
}