键入时输入占位符动画

时间:2019-01-10 02:58:18

标签: html css3 placeholder

我一直在尝试找到一种在用户开始键入时在占位符上模仿以下动画的方法,就像在以下GIF中一样:

Placeholder animation

一旦用户专注于输入,我就知道如何为动画的淡出设置动画,但是我还没有发现有关如何在用户开始键入动画时进行动画制作的任何信息

1 个答案:

答案 0 :(得分:0)

  

以下是您要在占位符中放置动画的解决方案

from os import urandom
letters = "ABCDEFGHJKLMNPRSTUVWXYZ"
password = "".join(letters[ord(c) % len(letters)] for c in urandom(6))
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;
}