jeudi 31 août 2017

Sass @if directive take multiple conditionals? [duplicate]

This question already has an answer here:

I'm writing a @mixin that handles both pseudo elements and classes. I essentially need my mixin to listen for before and after and then do something different to what it would if it was a pseudo class. My current code is as follows:

@mixin pseudo($elem) {
  @if $elem == "before" {
    // perform task
  } @else if $elem == "after" {
    // perform same task
  }
}

My question is "Can the @if directive take two conditionals?" Leaning on my JS knowledge, I am wondering if something like the following is possible so that I can remove the @else if from the statement:

@mixin pseudo($elem) {
  @if (($elem == "before") || ($elem == "after")) {
    // perform the one task
  }
}

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire