V
V
Vadim Belkin2015-02-19 13:27:17
css
Vadim Belkin, 2015-02-19 13:27:17

How to set a multigradient through loop?

In CSS, I set several radial gradients for the element (in the example, two, but in general, from 1 to 4 is needed)

.element {
background: radial-gradient(25% 20px at 25% 20px, rgba(0, 0, 0, .1) 0%, transparent 100%), radial-gradient(25% 20px at 75% 20px, rgba(0, 0, 0, .1) 0%, transparent 100%);
}

Is it possible to make in LESS that the background parameter is set in a loop, depending on the number of gradients transferred? In the gradient parameters, only the part that is set as a percentage (25%, 75%) changes.
One output was found
.loop-shadow(@counter, @i: 1) when (@i =< @counter) {
  .loop-shadow(@counter, (@i + 1));
  background-image+: radial-gradient((50% / @counter) 20px at ((50% / @counter) * (2 * @i - 1)) 20px, rgba(0, 0, 0, .1) 0%, transparent 100%);
}

Generates as needed, but the problem is that in this way I can not set two background-image -webkit-radial-gradient and radial-gradient separate background-image elements, as they merge into one

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2015-02-19
@paradoxo

There are no loops in LESS, you have to use separate variables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question