生成类的循环更少
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了生成类的循环更少相关的知识,希望对你有一定的参考价值。
Generate numbered classes and apply variable mixins.Base from [http://blog.thehippo.de/2012/04/programming/do-a-loop-with-less-css/](http://blog.thehippo.de/2012/04/programming/do-a-loop-with-less-css/)
// mixins to call inside loop .applyMixin('gridSpan', @index) { #grid > .span-width(@index); } .applyMixin('gridPush', @index) { #grid > .indent(@index); } .applyMixin('gridPull', @index) { } // helper class, will never show up in resulting css // will be called as long the index is above 0 .loop (@index, @class: item, @mixin: '') when (@index > 0) { // create the actual css selector // call styles through mixin .applyMixin(@mixin, @index); } // next iteration .loop(@index - 1, @class, @mixin); } // end the loop when index is 0 .loop (0) {}
以上是关于生成类的循环更少的主要内容,如果未能解决你的问题,请参考以下文章