Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have a number of things going on here that aren't quite right.</p> <pre><code>// If this is part of a reusable library, use the default flag // I typically prefer prefixing global variables to avoid collisions with other code // (eg. $grid-colCount instead of $colCount) $colCount: 2 !default; $colSpan: 1 !default; $gutter: 4% !default; // Mixin changed to a function, better for its intended purpose @function width($colCount: $colCount, $colSpan: $colSpan, $gutter: $gutter) { @return $colSpan * ((100% - $gutter) / $colCount); } // The arguments are set to our global variables by default @mixin columns($colCount: $colCount, $colSpan: $colSpan, $gutter: $gutter) { @content; // Something weird was going on here that just plain didn't compile width: width($colCount, $colSpan, $gutter); &amp;.first { // This is where your mixin was getting messed up, // it wasn't passing the values it received on to the mixins @include first($colCount, $colSpan, $gutter); } &amp;.only { @include only($colCount, $colSpan, $gutter); } &amp;.firstOnly { @include firstOnly($colCount, $colSpan, $gutter); } } @mixin first($colCount: $colCount, $colSpan: $colSpan, $gutter: $gutter) { margin-left: 100% - width($colCount, $colSpan, $gutter); } @mixin only($colCount: $colCount, $colSpan: $colSpan, $gutter: $gutter) { margin-left: 100% - (2 * width($colCount, $colSpan, $gutter)) - (2 * $gutter); } @mixin firstOnly($colCount: $colCount, $colSpan: $colSpan, $gutter: $gutter) { margin-left: 100% - width($colCount, $colSpan, $gutter) - $gutter; margin-right: 100% - width($colCount, $colSpan, $gutter); } </code></pre> <p>When we call the mixins like this:</p> <pre><code>.test { @include columns(3, 8, 40%); } .test2 { @include columns; } </code></pre> <p>We get this result:</p> <pre><code>.test { width: 160%; } .test.first { margin-left: -60%; } .test.only { margin-left: -300%; } .test.firstOnly { margin-left: -100%; margin-right: -60%; } .test2 { width: 48%; } .test2.first { margin-left: 52%; } .test2.only { margin-left: -4%; } .test2.firstOnly { margin-left: 48%; margin-right: 52%; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload