scss-@else if指令


  @else if語句用來與@if指令一起使用。當 @if 語句失敗時,則 @else if 語句測試,如果它們也無法測試滿足時再 @else 執行。

  語法:

@if expression {
   // CSS codes
} @else if condition {
   // CSS codes
} @else {
   // CSS codes
}

  scss代碼實例:

$type: audi;
p {
  @if $type == benz {
    color: red;
  } @else if $type == mahindra {
    color: blue;
  } @else if $type == audi {
    color: green;
  } @else {
    color: black;
  }
}

  編譯后的css代碼如下:

p {
  color: green; 
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM