<div class="cp_iptxt">
<input class="ef" type="text" placeholder="">
<label>お名前</label>
<span class="focus_line"></span>
</div>
.cp_iptxt {
position: relative;
width: 80%;
margin: 40px 3%;
}
.cp_iptxt input[type='text'] {
font: 15px/24px sans-serif;
box-sizing: border-box;
width: 100%;
letter-spacing: 1px;
padding-left: 4em;
}
.cp_iptxt input[type='text']:focus {
outline: none;
}
.ef {
padding: 4px 0;
border: 0;
border-bottom: 1px solid #1b2538;
background-color: transparent;
}
.ef ~ .focus_line {
position: absolute;
z-index: 99;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
}
.ef ~ .focus_line:before,
.ef ~ .focus_line:after {
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 100%;
content: '';
transition: 0.4s;
background-color: #da3c41;
}
.ef ~ .focus_line:after {
right: 0;
left: auto;
}
.ef:focus ~ .focus_line:before,
.ef:focus ~ .focus_line:after,
.cp_iptxt.ef ~ .focus_line:before,
.cp_iptxt.ef ~ .focus_line:after {
width: 50%;
transition: 0.4s;
}
.ef ~ label {
position: absolute;
z-index: -1;
top: 4px;
left: 0;
width: 100%;
transition: 0.3s;
letter-spacing: 0.5px;
color: #aaaaaa;
}
.ef:focus ~ label,
.cp_iptxt.ef ~ label {
font-size: 12px;
top: -16px;
transition: 0.3s;
color: #da3c41;
}