การเชื่อมส่วนของซีเลกเตอร์ใน SASS

สามารถเชื่อมแม้แต่ส่วนของคลาสเดียวกัน ตัวอย่างเช่น ดังนี้:

styles.scss.button {
  &-ok {
    color: green;
  }
  &-cancel {
    color: red;
  }
}

ผลลัพธ์หลังจากการคอมไพล์ เราจะได้ โค้ดต่อไปนี้:

styles.css.button-ok {
  color: green;
}
.button-cancel {
  color: red;
}
Задание 1

ลดความซับซ้อนของโค้ดที่ให้มา:

styles.scss.label-success {
  color: green;
}
.label-warning {
  color: yellow;
}
.label-error {
  color: red;
}