SASS'ta Kalıtım Çalışma Prensipleri

@extend direktifinin çalışma mantığı şudur: genişletilen seçicinin (örneğimizde .warning) bulunduğu her stil grubuna, genişleyen seçiciyi ekler.

Bir örnek inceleyelim:

style.scss.warning {
  border: 1px solid;
  background-color: #ffd900;
}
.warning .instruction {
  background-image: url("/image/warning.png");
}
.personalWarning {
  @extend .warning;
  border-width: 3px;
}

Şimdi derleme sonucuna bakalım:

style.css.warning, .personalWarning {
  border: 1px solid;
  background-color: #ffd900;
}

.warning .instruction, .personalWarning .instruction {
  background-image: url("/image/warning.png");
}
    
.personalWarning {
  border-width: 3px;
}
Задание 1

Aşağıdaki kodun derleme sonucu ne olur?

styles.scss#product-card p{
  color: #460707;
  padding: 10px;
}

#product-card-title {
  @extend #product-card;
  font-weight: 600px;
}
Задание 2

Aşağıdaki kodun derleme sonucu ne olur?

styles.scss.link .main-block{
  font-size: 14px;
  text-decoration: dashed;
}

.active-link {
  @extend .link;
  color: red;
}
Задание 3

Aşağıdaki kodun derleme sonucu ne olur?

styles.scss.link .main-block{
  font-weight: bold;
  text-decoration: none;
}

.active {
  color: red;
}

.active-link {
  @extend .link;
  @extend .active;
}