انتقال متغیرها به Mixin(Passing Variables to a Mixin)

میکس‌ها آرگومان‌ها را می‌پذیرند. به این ترتیب می توانید متغیرها را به یک mixin منتقل کنید.


در اینجا نحوه تعریف میکس با آرگومان آمده است:



SCSS Syntax:



/* Define mixin with two arguments */
@mixin bordered($color, $width) {
  border:
$width solid $color;
}

.myArticle {
  @include bordered(blue, 1px); 
// Call mixin with two values
}


.myNotes {
  @include bordered(red, 2px); // Call mixin with two values
}





توجه داشته باشید که آرگومان ها به عنوان متغیر تنظیم می شوند و سپس به عنوان مقادیر استفاده می شوند
(رنگ و عرض) ویژگی حاشیه.



پس از کامپایل، CSS به این شکل خواهد بود:



CSS Output:



.myArticle {
  border: 1px solid blue;
}


.myNotes {
  border: 2px solid red;
}


Run مثال »