SASS හි mixins භාවිතා කිරීම

අපි mixin එකක් ප්‍රකාශයට පත් කිරීමෙන් පසුව අපි එය @include නිදහස් යෙදුම මගින් අමතන්නෙමු, එයට අනිවාර්යයෙන්ම ඇතුළත් විය යුතුය mixin හි නම. එහි ද විකල්පයක් ලෙස පරාමිතීන් සහ විලාසිතා තිබිය හැකිය. අපි උදාහරණයක් බලමු:

styles.scss@mixin mix{
  width: 100px;
  height: 100px;
}
div {
  @include mix;
  padding: 4px;
  margin-top: 10px;
} 

සංකලනය කිරීමේ ප්‍රතිඵලය:

styles.cssdiv {
  width: 100px;
  height: 100px;
  padding: 4px;
  margin-top: 10px;
}

Mixins අමතා ගත හැකි අතර එය මූලයේ ද ය ලේඛනය, නමුත් එම අවස්ථාවේ දී පමණක්, ඔවුන් නීති විස්තර නොකරන විට සහ ඔවුන්ට මව්පියා ගැන යොමුවක් නොමැත. පහත උදාහරණය බලන්න:

styles.scss@mixin active {
  p {
    color: #161618;
    background-color: red;
  }
}
@include active;

සංකලනය කිරීමෙන් පසු අපට පෙනෙන්නේ:

styles.cssp {
  color: #161618;
  background-color: red;
}
Задание 1

පහත කේතය සංකලනය කිරීමේ ප්‍රතිඵලය කුමක් දැයි පැහැදිලි කරන්න පහත දැක්වෙන:

styles.scss@mixin font {
  font-family:'Courier New', Courier, monospace;
  font-size: 12px;
}

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

පහත කේතය සංකලනය කිරීමේ ප්‍රතිඵලය කුමක් දැයි පැහැදිලි කරන්න පහත දැක්වෙන:

styles.scss@mixin style {
  color:#090957;
}

button, link {
  @include style;
  font-size: 10px;
  padding: 4px;
}
Задание 3

පහත කේතය සංකලනය කිරීමේ ප්‍රතිඵලය කුමක් දැයි පැහැදිලි කරන්න පහත දැක්වෙන:

styles.scss@mixin active-text {
  font-size: 14px;
  font-weight: bold;
  text-decoration: underline;
  color: blue;
}

#product-card, .active, .content {
  @include active-text;
  padding: 4px;
} 
Задание 4

පහත කේතය සංකලනය කිරීමේ ප්‍රතිඵලය කුමක් දැයි පැහැදිලි කරන්න පහත දැක්වෙන:

styles.scss@mixin size {
  font-size: 14px;
  padding: 10px;
  margin: 4px;
}

@mixin color {
  color: #580909;
  background-color: #e9e5ab;
}

#product-card {
  @include size;
  @include color;
  width: 600px;
}