: 반복되는 CSS 코드를 하나의 묶음으로 만들어 필요할 때마다 불러서 사용하는 기능
-> 컴포넌트 정의와 같음
@mixin box-base() {
width: 200px;
height: 200px;
background-color: #34cfeb;
border-radius: 1.2rem;
margin: 10px;
transition: all .3s ease;
&:hover {
background-color: #6d2fc4;
}
}
: mixin 호출
.box-1 {
@include box-base();
}
-> mixin에서 변경하고 싶다면 바로 밑에 작성하면 됨
@mixin box-base($btn-bg-color, $font-size) {
width: 200px;
height: 200px;
background-color: $btn-bg-color;
font-size: $font-size;
}
.box-1 {
@include box-base(#d63eb8, 2rem);
}
@mixin box-base(
$btn-bg-color: #31eb69,
$font-size: 1.3rem,
$width: 150px,
$height: 150px
) {
width: $width;
height: $height;
background-color: $btn-bg-color;
font-size: $font-size;
}
.box-1 {
@include box-base(#34cfeb, 2rem, 300px, 250px);
}