sass功能强大,特别是支持for循环,节省大量开发时间,但是在开发时遇到一个问题,直接使用%时没有问题,当有变量时再加% 单位在编译时报错;

Sass for循环中编译%时报错解决方案

这样没有问题:

@for $width from 0 to 10{
    .wp#{$width}{
        width:$width px;
    }
}

但是这样就有问题了:

@for $width from 0 to 10{
    .wp#{$width}{
        width:$width%;
    }
}

或者这样:

@for $width from 0 to 10{
    .wp#{$width}{
        width:$width %;
    }
}

编译时报错,试了好多方法还是不行,最后采用很二的方式竟然可以了:

@for $width from 0 to 10{
    .wp#{$width}{
        width:$width+0%;
    }
}

Sass for循环中编译%时报错解决方案

相关文章:

  • 2021-08-29
  • 2021-06-23
  • 2022-12-23
  • 2021-06-08
  • 2022-01-19
  • 2022-03-02
  • 2021-05-16
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
相关资源
相似解决方案