小编Eri*_*nke的帖子

轻松在mixin中重复选择器声明

我正在尝试为某些表行声明背景图像图标:

.i(@file:'file.png', @type) {
    &.@{type} {
      td:first-child {
        background-image: url('../img/@{file}');
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

我希望能够同时传递多种图像类型:

.i('code.png', 'asp, php, rb, py')
Run Code Online (Sandbox Code Playgroud)

并有效地做到这一点:

.i(@file:'file.png', @type) {
  &.@{type1},
  &.@{type2},
  &.@{type3},
  &.@{type4}, {
    td:first-child {
      background-image: url('../img/@{file}');
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我知道CSS输出会有所不同,最后一个代码示例仅用于说明目的.

关于如何实现这一点的任何想法,只是将一堆空选择器声明为占位符?

css css-selectors less

3
推荐指数
1
解决办法
2278
查看次数

标签 统计

css ×1

css-selectors ×1

less ×1