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

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

这样没有问题:spa

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

可是这样就有问题了:code

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

或者这样:blog

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

编译时报错,试了好多方法仍是不行,最后采用很二的方式居然能够了:开发

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

相关文章
相关标签/搜索