Last active
August 29, 2015 14:02
-
-
Save AllThingsSmitty/2e51aba6f4a53a36df5b to your computer and use it in GitHub Desktop.
A way to add an border/outline to an element without affecting its final dimensions
This file contains hidden or 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
// default values: | |
$ibThickness: 2px !default; | |
$ibColor: black !default; | |
$ibAlpha: .1 !default; | |
// use a "variable argument" to accept any number of values. | |
@mixin ib($values...) { | |
$borderThickness: $ibThickness; | |
$borderColor: $ibColor; | |
$borderAlpha: $ibAlpha; | |
@each $value in $values { | |
@if type_of($value) == number { | |
@if unit($value) == "" { | |
$borderAlpha: $value; | |
} | |
@else { | |
// no need to limit this length to just "px" | |
$borderThickness: $value; | |
} | |
} | |
@else if type_of($value) == color { | |
$borderColor: $value; | |
} | |
} | |
box-shadow: inset 0 0 0 $borderThickness rgba($borderColor, $borderAlpha); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment