<div class="form__group">
<input type="input" class="form__field" placeholder="Name" required="">
<label for="name" class="form__label">Name</label>
</div>
*{
box-sizing:border-box;
margin:0;
padding:0;
}
body {
height:100vh;
display:flex;
align-items:center;
justify-content:center;
background-color: #212121;
font-family:arial;
}
.form__group {
position: relative;
padding: 20px 0 0;
width: 100%;
max-width: 180px;
}
.form__field {
font-family: inherit;
width: 100%;
border: none;
border-bottom: 2px solid #9b9b9b;
outline: 0;
font-size: 17px;
color: #fff;
padding: 7px 0;
background: transparent;
transition: border-color 0.2s;
}
.form__field::placeholder {
color: transparent;
}
.form__field:placeholder-shown ~ .form__label {
font-size: 17px;
cursor: text;
top: 20px;
}
.form__label {
position: absolute;
top: 0;
display: block;
transition: 0.2s;
font-size: 17px;
color: #9b9b9b;
pointer-events: none;
}
.form__field:focus {
padding-bottom: 6px;
font-weight: 700;
border-width: 3px;
border-image: linear-gradient(to right, #116399, #38caef);
border-image-slice: 1;
}
.form__field:focus ~ .form__label {
position: absolute;
top: 0;
display: block;
transition: 0.2s;
font-size: 17px;
color: #38caef;
font-weight: 700;
}
.form__field:required, .form__field:invalid {
box-shadow: none;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.