In this tutorial we will see how to make a Simple Login Form with Placeholder Animation. Simple CSS is used for this purpose, HTML code and CSS code is given.
Table of Contents
HTML Code
HTML Code is given below.
<form class="form">
<h1>Login Form</h1>
<p>Please Enter Login Details</p>
<div class="input-group">
<input type="email" class="input">
<label class="placeholder">Email</label>
</div>
<div class="input-group">
<input type="password" class="input">
<label class="placeholder">Password</label>
</div>
<input class="submit" type="submit" value="Login">
</form>
CSS Code
CSS Code is given below.
body
{
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background-color: #5469D4;
font-family: 'Barlow Condensed' , sans-serif;
}
.form
{
background-color: #fff;
padding: 20px;
width: 100%;
max-width: 300px;
box-sizing: border-box;
border-radius: 5px;
box-shadow: 0px 0px 10px 0px #666;
}
.form h1
{
font-size: 24px;
text-align: center;
margin-bottom: 30px;
}
.form p
{
font-size: 16px;
margin: 40px 0px 0px 0px;
}
.input
{
padding: 10px;
width: 100%;
box-sizing: border-box;
max-width: 300px;
outline: none;
border: 1px solid #5469D4;
}
.input-group
{
position: relative;
margin: 30px 0px;
}
.placeholder
{
position: absolute;
top: 10px;
left: 8px;
font-size: 14px;
padding: 0px 5px;
color: #333;
transition: top 0.3s;
pointer-events: none;
background-color: #fff;top: -10px;
}
.submit
{
background-color: #5469D4;
color: #fff;
border: 0px;
padding: 5px 10px;
cursor: pointer;
float: right;
box-shadow: 0px 0px 3px 0px #666;
}
.input:focus + .placeholder
{
top: -10px;
}
Demo
Video Tutorial
Watch our video tutorial on Simple Login Form with Placeholder Animation.