Last active
December 24, 2015 12:39
-
-
Save ethnt/6798751 to your computer and use it in GitHub Desktop.
Make a rainbow border like on CreativeMornings.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import compass/css3 | |
// A lot of this is taken from Hugo Giraudel's post on CSS Tricks | |
// about this: http://css-tricks.com/striped-background-gradients/ | |
// Create a rainbow-style border before or after an element. | |
// | |
// rainbows([$position, $size, $colors...]) | |
@mixin rainbows($position, $size, $colors...) | |
$stripe-width: 100% / length($colors) | |
$gradient: () | |
@for $i from 1 through length($colors) | |
$item: nth($colors, $i) | |
$dump: () | |
$dump: $item $stripe-width * ($i - 1), $item $stripe-width * $i | |
$gradient: join($gradient, $dump, comma) | |
@if $position == top | |
&:before | |
+rainbows-generic($position, $size) | |
+background(linear-gradient(left, $gradient)) | |
@else if $position == bottom | |
&:after | |
+rainbows-generic($position, $size) | |
+background(linear-gradient(left, $gradient)) | |
// Styles for all borders, independent of what colors are being used | |
// | |
// rainbows-generic([$position, $size]) | |
@mixin rainbows-generic($position, $size) | |
content: '' | |
display: block | |
height: $size | |
position: absolute | |
left: 0 | |
right: 0 | |
line-height: 1 | |
z-index: 1 | |
@if $position == top | |
top: 0 | |
@else if $position == bottom | |
bottom: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An example of using the rainbows mixin | |
body | |
+rainbows(top, 5px, blue, green) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment