Gradient Borders using SCSS Mixins

HTML
<div class="wrapper"> <div class="input"> <input class="inner-input" type="text" placeholder="Type Something ..."> <div class="input-big"></div> </div> </div>
SCSS
$pink: #E5446D; $blue: #52BDF2; * { box-sizing: border-box; } body { background-color: #222; } @mixin gradient-border($color1, $color2, $border-width, $direction) { border: none; background-repeat: no-repeat; background-image: linear-gradient(#{$direction}, $color1 0%, $color2 100%), linear-gradient(#{$direction}, $color1 0%, $color2 100%); @if $direction == 'to right' or $direction == 'to left' { @if $direction == 'to right' { border-left: $border-width solid $color1; border-right: $border-width solid $color2; } @else { border-left: $border-width solid $color2; border-right: $border-width solid $color1; } background-position: 0 0, 0 100%; background-size: 100% $border-width; } @if $direction == 'to top' or $direction == 'to bottom' { @if $direction == 'to top' { border-top: $border-width solid $color2; border-bottom: $border-width solid $color1; } @else { border-top: $border-width solid $color1; border-bottom: $border-width solid $color2; } background-position: 0 0, 100% 0; background-size: $border-width 100%; } } .wrapper { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .input { width: 450px; } .inner-input { position: relative; font-size: 36px; width: 100%; padding: 0.5em 0.6em; line-height: 1.4; -webkit-appearance: none; border-radius: 2px; @include gradient-border($pink, $blue, 3px, 'to right'); background-color: transparent; color: white; &::-webkit-input-placeholder { color: #eee; font-family: 'Proxima Nova', 'futura', 'helvetica'; transition: color 0.2s ease-out; } &:focus { outline: none; &::-webkit-input-placeholder { color: white; } ~ .input-big {; opacity: 1; } } } .input-big { display: block; position: absolute; z-index: -1; opacity: 0; top: 0; left: 0; width: 100%; height: 100%; background-image: linear-gradient(to right, $pink 0%, $blue 100%), linear-gradient(to right, $pink 0%, $blue 100%); transition: all 0.3s ease-out; }
JAVASCRIPT
Expand for more options Login