Loops are one of those features that you don’t need every day. But when you do, it’s awfully nice that preprocessors can do it because native HTML and CSS cannot.
Sass (SCSS)
for
Loop
while
Loop
each
Loop
Less
for
Loop
while
Loop
(That’s what the above is. The when
clause could be thought of exactly as while
.)
each
Loop
Stylus
for
Loop
while
Loop
Only for
loops in Stylus.
each
Loop
The for
loop actually behaves more like an each
loop, so here’s a more obvious each
loop example:
I never understood the meaning of preprocessors. As long as you have PHP available, why using something else. With DynCSS – CSS per PHP you can just use CSS within PHP, use variables, loops, if-else, cases, etc.
http://www.cms-hamburg.de/?content=2020_10_20_1001
(it’s Germany, but if you download the files (ZIP) you can see how easy it it. No compiling, now other script language to learn. Just pure PHP, easy and readable CSS as minified output.
CSS-in-PHP. That’s just what we needed…