纯CSS3实现漂亮的input输入框动画样式库(Text input love)

2020-05-16 07:14:32易采站长站整理

}
100% {
transform: rotate(82deg);
}
}
@keyframes swing-back {
0% {
transform: rotate(82deg);
}
100% {
transform: rotate(0);
}
}
.swing:focus,
.swing:active {
color: #377D6A;
text-indent: 0;
background: #fff;
border-top-left-radius: 0;
border-bottom-left-radius: 0;

&::-webkit-input-placeholder {
color: #aaa;
}
+ label {
animation: swing 1.4s 1 ease-in-out;
transform: rotate(82deg);
}
}
.balloon {
// As suggested by https://twitter.com/dbox/status/365888496486985728
display: inline-block;
width: 215px;
padding: 10px 0 10px 15px;
font-family: "Open Sans", sans;
font-weight: 400;
color: #377D6A;
background: #efefef;
border: 0;
border-radius: 3px;
outline: 0;
text-indent: 60px; // Arbitrary.
transition: all .3s ease-in-out;

&::-webkit-input-placeholder {
color: #efefef;
text-indent: 0;
font-weight: 300;
}

+ label {
display: inline-block;
position: absolute;
top: 8px;
left: 0;
bottom: 8px;
padding: 5px 15px;
color: #032429;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(19,74,70,0);
transition: all .3s ease-in-out;
border-radius: 3px;
background: rgba(122,184,147,0);

&:after {
position: absolute;
content: "";
width: 0;
height: 0;
top: 100%;
left: 50%;
margin-left: -3px;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 3px solid rgba(122,184,147,0);
transition: all .3s ease-in-out;
}
}
}
.balloon:focus,
.balloon:active {
color: #377D6A;
text-indent: 0;
background: #fff;

&::-webkit-input-placeholder {
color: #aaa;
}
+ label {
color: #fff;
text-shadow: 0 1px 0 rgba(19,74,70,.4);
background: rgba(122,184,147,1);
transform: translateY(-40px);

&:after {
border-top: 4px solid rgba(122,184,147,1);
}
}
}