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

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

</span>
</div>

SCSS 代码:

Sass 代码:


@import "compass/css3";

@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300,800);

* {
box-sizing: border-box;
}
html,
body {
overflow-x: hidden;
font-family: "Open Sans", sans-serif;
font-weight: 300;
color: #fff;
background: #efefef;
}
@mixin epic-sides() { // https://codepen.io/MichaelArestad/pen/qltuk
position: relative;
z-index: 1;

&:before {
position: absolute;
content: "";
display: block;
top: 0;
left: -5000px;
height: 100%;
width: 15000px;
z-index: -1;
@content;
}
}
.row {
max-width: 800px;
margin: 0 auto;
padding: 60px 30px;
background: #032429;
@include epic-sides() {background: inherit;}
text-align: center;

&:first-child {
padding: 40px 30px;
}
&:nth-child(2),
&:nth-child(8),
&:nth-child(10){
background: #134A46;
}
&:nth-child(3),
&:nth-child(7) {
background: #377D6A;
}
&:nth-child(4),
&:nth-child(6) {
background: #7AB893;
}
&:nth-child(5) {
background: #B2E3AF;
}

span {
position: relative;
display: inline-block;
margin: 30px 10px;
}
}
.basic-slide {
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: 70px; // 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: 0;
left: 0;
padding: 10px 15px;
text-shadow: 0 1px 0 rgba(19,74,70,.4);
background: #7AB893;
transition: all .3s ease-in-out;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
}
.basic-slide:focus,
.basic-slide:active {
color: #377D6A;
text-indent: 0;
background: #fff;
border-top-left-radius: 0;
border-bottom-left-radius: 0;

&::-webkit-input-placeholder {
color: #aaa;
}
+ label {
transform: translateX(-100%);
}
}
.clean-slide {
position: relative;
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;
}