# vue输入框打字放大特效

# 快速导航

# 示例



# 示例代码

<template>
        <div>
		    <div class="nice-input">
				<input type="text" placeholder="请输入文字" id="test" v-model="message" />
				<label for="test">
				    <span class="nice-input__animate" v-for="m in message2">{{m}}</span>
				</label>
    		</div>
		</div>
</template>

<script>
    export default {
		data() {
			return {
				message: ''
			}
		},

		watch: {
			message: {
			handler: function(after,before){
				if (after.length > before.length) {
				setTimeout(function(){
					document.querySelector('.nice-input').classList.add('shake');
				setTimeout(function(){
					document.querySelector('.nice-input').classList.remove('shake'); 
				},300); 
				},200);
				}
			}
          }
  		},
	   computed: {
		  message2: function(){
			return this.message.split('');
		  }
	   }
    }
</script>

<style scoped>
.nice-input {
  position: absolute;
  margin-top:20px;
  margin-bottom: 20px;
}

.nice-input input {
  border:none;
  border-radius:4px;
  padding:7px 10px;
  font-family: 'Lato', sans-serif;
  font-size:14px;
  box-shadow: rgba(0,0,0,.05) 0 5px 20px;
  letter-spacing:0;
  width:165px;
  color: transparent;
  font-weight:900;
}

.nice-input input:focus {
  outline:none;
  box-shadow: rgba(0,0,0,.1) 0 5px 20px;
}

.nice-input label {
  position: absolute;
  top: 6px;
  left: 10px;
  letter-spacing:0;
  font-size:0;
}

.nice-input span {
  font-family: 'Lato', sans-serif;
  font-size:14px;
  font-weight:900;
}

.nice-input__animate {
  -webkit-animation: print .2s 1 ease-in-out;
          animation: print .2s 1 ease-in-out;
}

.shake {
  -webkit-animation: shake .2s 1 ease-in-out;
          animation: shake .2s 1 ease-in-out;
}

@-webkit-keyframes print {
  from{
    position:absolute;
    -webkit-transform: scale(50);
          transform: scale(50);
      /* uncomment for freeze */  
     /*   filter:blur(1px); */
   }
  99% {
    position:absolute;
  }
  to {
    position:relative;
  }
}

@keyframes print {
  from{
  position:absolute;
  -webkit-transform: scale(50);
          transform: scale(50);
  /* uncomment for freeze */  
  /*   filter:blur(1px); */
  }
  99% {
    position:absolute;
  }
  to {
    position:relative;
  }
}

@-webkit-keyframes shake {
  from,
  to {
  }
  50% {
    -webkit-transform:scale(0.97);
            transform:scale(0.97);
  }
}

@keyframes shake {
  from,
  to {
  }
  50% {
    -webkit-transform:scale(0.97);
            transform:scale(0.97);
  }
}


</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
白色

关注公众号

一个走心,有温度的号,同千万同行一起交流学习

加作者微信

扫二维码 备注 【加群】

扫码易购

福利推荐