Анимация заполнителя INPUT при наборе текста - PullRequest
0 голосов
/ 10 января 2019

Я пытался найти способ имитировать следующую анимацию на заполнителях, когда пользователь начинает печатать, как в следующем GIF:

Анимация заполнителя

Я знаю, как анимировать затухание анимации, как только пользователь сфокусируется на вводе, но я пока не нашел ничего о том, как сделать эту анимацию, только когда пользователь начинает печатать

1 Ответ

0 голосов
/ 10 января 2019

Здравствуйте, ниже приведено решение, поскольку вы хотите анимацию в заполнителе

input[type="text"] {
    font: 15px/24px "Lato", Arial, sans-serif;
    color: #333;
    width: 100%;
    box-sizing: border-box;
    letter-spacing: 1px;
}
.effect-16, .effect-17, .effect-18 {
    border: 0;
    padding: 4px 0;
    border-bottom: 1px solid #ccc;
    background-color: transparent;
}
.effect-16 ~ label {
    position: absolute;
    left: 0;
    width: 100%;
    top: 9px;
    color: #aaa;
    transition: 0.3s;
    z-index: -1;
    letter-spacing: 0.5px;
}
.effect-16 ~ .focus-border {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: #3399FF;
    transition: 0.4s;
}
.effect-16:focus ~ .focus-border, .has-content.effect-16 ~ .focus-border {
    width: 100%;
    transition: 0.4s;
}
.effect-16 ~ .focus-border {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: #3399FF;
    transition: 0.4s;
    
}
input:focus {
  outline: 0;
}
.effect-16:focus ~ label, .has-content.effect-16 ~ label {
    top: -16px;
    font-size: 12px;
    color: #3399FF;
    transition: 0.3s;
}
.input-box {padding:50px 0px;}
.col-3 {
    float: left;
    width: 27.33%;
    margin: 40px 3%;
    position: relative;
}
<section class="input-box">
  <div class="container">
  
  
        <div class="row">
                    <div class="col-3 input-effect">
        	<input class="effect-16" type="text" placeholder="">
            <label>First Name</label>
            <span class="focus-border"></span>
        </div>
        <div class="col-3 input-effect">
        	<input class="effect-16" type="text" placeholder="">
            <label>Last Name</label>
            <span class="focus-border"></span>
        </div>
        <div class="col-3 input-effect">
        	<input class="effect-16" type="text" placeholder="">
            <label>Address</label>
            <span class="focus-border"></span>
        </div>
        <div class="col-3 input-effect">
        	<input class="effect-16" type="text" placeholder="">
            <label>Mobile</label>
            <span class="focus-border"></span>
        </div>
        </div>
</div>
        </section>
...