The function you're needing is abs()
. This will allow you to strip out the negative sign before you do your calculation, then add it back on at the end:
@function calculate-width($cols) {
$width: round(abs($cols) * ($column-width + $gutter-width) - $gutter-width);
@return $width * ($cols / abs($cols));
}
.div {
@include width(margin-left, 5);
@include width(margin-left, -5);
}
Output:
.div {
margin-left: 280px;
margin-left: -280px;
}