A
A
aweui2019-03-05 07:29:14
css
aweui, 2019-03-05 07:29:14

What is css guard?

Hello.
I googled, honestly, but did not find the answer.
I'm assuming it's some sort of security feature?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
titelhalter, 2019-03-05
@aweui

I haven't heard about css guards, but they are in the less preprocessor. In fact, these are conditions, the fulfillment or non-fulfillment of which leads to different results. A simple example from the less documentation:

.mixin(@a) when (@media = mobile) { ... }
.mixin(@a) when (@media = desktop) { ... }

The conditions inside when are guards. Another example is a loop (in fact, there are no loops in less, but there is a recursion, which guard helps to get out of).
.
loop(@counter) when (@counter > 0) {
  .loop((@counter - 1));    // next iteration
  width: (10px * @counter); // code for each iteration
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question