Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 2

sass-mixin

how to make mixin with argument with different url of background-image property??
it does not compiling with me to css :

@mixin sm-icon($url) {

background-image:url($url);
background-repeat: no-repeat;
background-size: contain;

}

1 Reply
Community Manager
Message 2 of 2

Re: sass-mixin

A mixin is only a declaration and generates no CSS if it isn't used somehow. So if the code you showed in your post is the only code, it would generate no CSS. You would have to have something like the following to generate code:

 

@mixin sm-icon($url) {
  background-image: url($url);
  background-repeat: no-repeat;
  background-size: contain;
}

.cat-icon {
  @include sm-icon(https://placekitten.com/g/200/300);
}

See the Sass documentation on mixins for more details.

 

I hope that helps!