Sass的@while指令

来源:互联网 发布:盗取qq软件 编辑:程序博客网 时间:2024/06/08 08:56

@while指令也需要SassScript表达式(像其他指令一样),并且会生成不同的样式块,直到表达式值为false时停止循环。这个和@for指令很相似,只要@while后面的条件为true就会执行。

scss语法:

$types: 4;$type-width: 20px;@while $types > 0 {    .while-#{$types}    {        width: $type-width + $types;    }    $types: $types - 1;}

编译出CSS:

.while-4 {  width: 24px;}.while-3 {  width: 23px;}.while-2 {  width: 22px;}.while-1 {  width: 21px;}
原创粉丝点击