Search code examples
cssfunctionsassmixins

Halving All Numbers in SCSS Sheet


I have a SCSS drawing that I am working on using a large number of box shadows on one element. However, once I finished the drawing, I realized that I needed the drawing to be much smaller. Is there a way to halve all number values using a Sass function or mixin? Here's a link to my codepen. Here's my code:

HTML

<div class="bowser"></div>

SCSS

.bowser {
  height: 0.98em;
  width: 0.98em;
  box-shadow:
    /* row 1 */
    12em 0 $w,
    13em 0 $w,
    14em 0 $w,
    /* row 2 */
    8em 1em $g,
    9em 1em $g,
    10em 1em $w,
    11em 1em $w,
    12em 1em $w,
    13em 1em $t,
    /* etc. etc. */
}

If this is not possible using Sass, is there a way to do it using a compiler-like service? Thanks for the help!


Solution

  • Yes. Here is your updated CodePen http://codepen.io/anon/pen/xdEQXV?editors=1100

    @mixin box-shadow-mixin($divide) {
        box-shadow: 12em/$divide 0 $w,
        13em/$divide 0 $w,
        14em/$divide 0 $w,
        8em/$divide 1em/$divide $g,
        etc...
    }
    

    And then include this way:

    .bowser {
      height: 0.95em;
      width: 0.95em;
      @include box-shadow-mixin(4);
    }