Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

Storing all the array values into single variable and then using that value as css property through javascript

Suppose i have this array,

let array = [];

for (let i = 1; i < 101; i++) {
  const element = `${i}px ${i}px #0e96ff`;
  array.push(element);
}

now is it possible to store all the 100 values into single variable and then use that value as a css property like this:

let variable = array;

//css property
let style = { filter:`drop-shadow${vairable}`}

if no then how can i achieve the same result?

thanks in advance.

question from:https://stackoverflow.com/questions/65895757/storing-all-the-array-values-into-single-variable-and-then-using-that-value-as-c

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To do what you want with drop-shadow specifically:

let array = [];

for (let i = 1; i < 101; i++) {
  const element = `drop-shadow(${i}px ${i}px #0e96ff)`;
  array.push(element);
}

//css property
let style = { filter: array.join(' ')};

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...