Last active
December 10, 2015 15:08
-
-
Save joeldrapper/4452213 to your computer and use it in GitHub Desktop.
Handy little snippet for generating block shadows with SASS.
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
=vendor($property, $value) | |
-webkit-#{$property}: $value | |
-moz-#{$property}: $value | |
-o-#{$property}: $value | |
#{$property}: $value | |
=block-shadow($distance, $horizontal, $vertical, $color) | |
$property: null | |
$i: 1 | |
@while $i <= $distance | |
@if $horizontal == left and $vertical == bottom | |
$property: $property , -#{$i}px #{$i}px $color | |
@else if $horizontal == left and $vertical == top | |
$property: $property , -#{$i}px -#{$i}px $color | |
@else if $horizontal == right and $vertical == bottom | |
$property: $property , #{$i}px #{$i}px $color | |
@else if $horizontal == right and $vertical == top | |
$property: $property , #{$i}px -#{$i}px $color | |
$i: $i + 1 | |
+vendor(box-shadow, $property) | |
.box | |
+block-shadow(5px, left, bottom, #ddd) |
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
.box { | |
-webkit-box-shadow: -1px 1px #dddddd, -2px 2px #dddddd, -3px 3px #dddddd, -4px 4px #dddddd, -5px 5px #dddddd; | |
-moz-box-shadow: -1px 1px #dddddd, -2px 2px #dddddd, -3px 3px #dddddd, -4px 4px #dddddd, -5px 5px #dddddd; | |
-o-box-shadow: -1px 1px #dddddd, -2px 2px #dddddd, -3px 3px #dddddd, -4px 4px #dddddd, -5px 5px #dddddd; | |
box-shadow: -1px 1px #dddddd, -2px 2px #dddddd, -3px 3px #dddddd, -4px 4px #dddddd, -5px 5px #dddddd; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changed three of the if statements to else if statements for better performance.