mercredi 4 janvier 2017

Using @if statement inside a sass mixing outside the css selector brackets?

I'm having trouble getting an @if statement too work inside a @mixin.

This mixin is basically emulating an 'if less than or equal too' ie statement, as I'm using php to populate the body class.

// less than or equal too mixin
@mixin lte-ie($ver:'9') {
  @if $ver >= '9' { .ie-9 &, }
  @if $ver >= '8' { .ie-8 &, }
  @if $ver >= '7' { .ie-7 &, }
  .ie-6 &
  {
    @content;
  }
}

But the mixin fails and I get this error when I try and run it.

Invalid CSS after "...f $ver >= '9' {": expected "}", was ".ie-9 &, }" on line 9 at column 20

I've made a sassmeister but i've had to comment out the @mixin as you cannot save a broken gist.. but you can uncomment to test the above code :)

http://ift.tt/2izBRRM

Any help would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire