I want to display the label of an input inside its input, so that when I click the input, the label will animate and go above the input and change the styles of the input\'s bor
.box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 200px;
background: #fff;
padding: 40px;
border: 1px solid red;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}
.box input {
padding: 10px 0;
margin-bottom: 30px;
}
.box input {
width: 100%;
box-sizing: border-box;
box-shadow: none;
outline: none;
border: none;
border-bottom: 2px solid #999;
}
.box form div {
position: relative;
}
.box form div label {
position: absolute;
top: 10px;
left: 0;
color: #999;
transition: 0.5s;
pointer-events: none;
}
.box input:focus~label,
.box input:valid~label {
top: -12px;
left: 0;
color: red;
}
.box input:focus,
.box input:valid {
border-bottom: 2px solid red;
}