Last active
December 14, 2015 10:49
-
-
Save cocopon/5074659 to your computer and use it in GitHub Desktop.
Sass functions that extract a specified edge
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
// Example: | |
// | |
// $padding: 1px 2px 3px; | |
// top($padding) ...... 1px | |
// right($padding) .... 2px | |
// bottom($padding) ... 3px | |
// left($padding) ..... 2px | |
@function top($args) { | |
$len: length($args); | |
@if ($len >= 1 and $len <= 4) {@return nth($args, 1);} | |
} | |
@function right($args) { | |
$len: length($args); | |
@if ($len == 1) {@return nth($args, 1);} | |
@if ($len == 2) {@return nth($args, 2);} | |
@if ($len == 3) {@return nth($args, 2);} | |
@if ($len == 4) {@return nth($args, 2);} | |
} | |
@function bottom($args) { | |
$len: length($args); | |
@if ($len == 1) {@return nth($args, 1);} | |
@if ($len == 2) {@return nth($args, 1);} | |
@if ($len == 3) {@return nth($args, 3);} | |
@if ($len == 4) {@return nth($args, 3);} | |
} | |
@function left($args) { | |
$len: length($args); | |
@if ($len == 1) {@return nth($args, 1);} | |
@if ($len == 2) {@return nth($args, 2);} | |
@if ($len == 3) {@return nth($args, 2);} | |
@if ($len == 4) {@return nth($args, 4);} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment