特效描述:文本框输入动画 动画特效。几个更鼓舞人心的风格为文本框输入动画包括一些新技术和新思想。
代码结构
1. 引入CSS
2. 引入JS
3. HTML代码
Manami
Username
Website
Invitation Code
Nariko
Username
Website
Invitation Code
Nao
Username
Invitation Code
Yoshiko
Bird's Color
Wing Span
Beak Length
Shoko
Player Name
Village
World
Chisato
First Name
Middle Name
Last Name
Makiko
Search
Sae
Email Address
Invitation Code
Full Name
Kozakura
Name
Website
Fumi
Course Name
Degree
Work Place
Ruri
Username
Website
Invitation Code
Kohana
Time
Line
Phone
(function() {
// trim polyfill : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
if (!String.prototype.trim) {
(function() {
// Make sure we trim BOM and NBSP
var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
String.prototype.trim = function() {
return this.replace(rtrim, '');
};
})();
}
[].slice.call( document.querySelectorAll( 'input.input__field' ) ).forEach( function( inputEl ) {
// in case the input is already filled..
if( inputEl.value.trim() !== '' ) {
classie.add( inputEl.parentNode, 'input--filled' );
}
// events:
inputEl.addEventListener( 'focus', onInputFocus );
inputEl.addEventListener( 'blur', onInputBlur );
} );
function onInputFocus( ev ) {
classie.add( ev.target.parentNode, 'input--filled' );
}
function onInputBlur( ev ) {
if( ev.target.value.trim() === '' ) {
classie.remove( ev.target.parentNode, 'input--filled' );
}
}
})();