conditional - Syntax for if/else condition in SCSS mixin -


Hello I am trying to learn SASS / SCSS and I am trying to refactor my own pixel clearfix

What I want for a mixine should be based on whether I pass the mixine wide.

So far (pseudo-code only as I would have with other mixes)

  @Mixin Clearfix ($ width) {@if! $ Width {// if the width is not passed, or clear} @else {display: inline-block; Width: $ width; }}   

Here I thought I could call it, but it is not working.

@include clearfix ();

or

@include clearfix (100%)

or

@include clearfix (960px)

I appreciate any help to do this either the best or the right way!

You can try it: $ width: auto ; @Mixen Clearfix ($ width) {@if $ width == 'auto' {// if the width is not passed, or empty} @else {display: inline-block; Width: $ width; }}

I'm not sure of the result you want, but setting a default value should be wrong.

Comments