Is it possible to use variable names dynamically in SASS each loop? [duplicate]

…衆ロ難τιáo~ 提交于 2019-12-01 03:03:37

That's something that I wanted in SASS as well, but after reading their discussion list, I concluded that this kind of variable interpolation is not supported yet.

I didn't try Less, but their documentation suggests it would be possible with @@ syntax.

The alternative is to pass a map instead of item list for the @each directive. The following will work:

@each $animal, $width in (puma, 100px),
                         (slug, 200px) {
  .#{$animal}-title {
    width: #{$width};
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!