Home > Designing, Others > How to Write Loops with Preprocessors

How to Write Loops with Preprocessors

November 5th, 2020 Leave a comment Go to comments

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

CodePen Embed Fallback

while Loop

CodePen Embed Fallback

each Loop

CodePen Embed Fallback

Less

for Loop

CodePen Embed Fallback

while Loop

(That’s what the above is. The when clause could be thought of exactly as while.)

each Loop

CodePen Embed Fallback

Stylus

for Loop

CodePen Embed Fallback

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:

CodePen Embed Fallback

Pug

for Loop

CodePen Embed Fallback

while Loop

CodePen Embed Fallback

each Loop

CodePen Embed Fallback

Haml

for Loop

CodePen Embed Fallback

while Loop

CodePen Embed Fallback

each Loop

CodePen Embed Fallback

Slim

for Loop

CodePen Embed Fallback

while Loop

CodePen Embed Fallback

each Loop

CodePen Embed Fallback

The post How to Write Loops with Preprocessors appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.