How to define a dynamic mixin or function name in SASS?

前端 未结 3 587
情书的邮戳
情书的邮戳 2020-11-30 11:04

I want to dynamically create mixins in SASS, named after each item in the list, but it doesn\'t seem to work.

I tried this but I get an error:

$even         


        
3条回答
  •  無奈伤痛
    2020-11-30 11:57

    The best solution is to implement a single mixin that takes an argument.

    $event-icons: fair, concert, art-show, conference, dance-show, film, party, festival, theatre, launch
    @mixin event-icon($name)
      @if not index($event-icons, $name)
        @error "#{$name} is not an event icon."
      background-position: -($event-icon-width * $i) 0
    

提交回复
热议问题