📝 代码查看
使用runcode.html页面

2
查看次数
2025-11-21
创建时间
2025-11-21
最后更新
<div>
  <div class="abc abc--x">.abc.abc--x</div>
  <div class="abc abc--y">.abc.abc--y</div>
  <div class="abc abc--x abc--y">.abc.abc--x.abc--y</div>
</div>
@function string-remove-whitespace($string) {
  @while (str-index($string, " ") != null) {
    $index: str-index($string, " ");
    $string: #{str-slice($string, 0, $index - 1)}#{str-slice(
        $string,
        $index + 1
      )};
  }
  @return $string;
}

@function unify-selector($selectorA, $selectorB) {
  @return #{string-remove-whitespace(#{$selectorA$selectorB})};
}

.abc {
  display: inline-flex;
  line-height: 20px;
  padding: 10px;
  text-align: center;
  margin-bottom: 10px;
  border: 1px solid currentColor;

  &--x {
    background: #fcf;
  }

  &--y {
    color: #f00;
  }

  @at-root #{unify-selector(&--x, &--y)} {
    border-radius: 20px;
  }
}
暂无JavaScript代码

👁️ 实时预览