JSFiddle - React, Tailwind, and code Playground
HTML
<p class="head">Sign In</p>
<form>
<div class="username">
<input type="text" name="name" class="input-field" id="user"/> <!--input filed-->
<label for="user" class="label"><span>Username</span></label>
</div>
<br>
<br>
<div class="password">
<input type="text" name="name" class="input-field" id="pass" />
<label for="pass" class="label"><span>Password</span></label>
</div>
</form>
CSS
body {
background-color: #f0f0f0;
}
form {
margin-left: 39%;
margin-top: 9%;
}
label {
position: relative;
margin-left: 0%;
font-family: monospace, 'Montserrat', sans-serif;
font-size: 15px;
padding-top: 3px;
/* border: 5px solid black;*/
}
.head {
margin-left: 43%;
margin-top: 5%;
font-size: 25px;
font-family: monospace;
}
.password {
margin-top: 5%;
}
.input-field {
position: absolute;
background: transparent;
border-width: 2px;
border-top: 0;
border-left: 0;
border-right: 0;
background: transparent;
outline: 0;
height: 23px;
border-color: black;
width: 180px;
}
input:focus {
background: #fae596;
border: 0;
}
input:focus + .label {
top:-20px;
font-size: 15px;
color: blue; /* font color while on top */
}