javascript - dynamic amount of divs = dynamic color change steps? -


i want have dynamic amount of divs (sometimes 3, 10 etc), should colored based on color gradient (say green red).

so, when there 2 divs, make first 1 #0f0, second 1 #f00. when there 10 divs, make first , last same, between change gradually green red.

is there way pure css? if not, how javascript? i'm thinking doing javascript right now, it's gonna reaaally complicated way think it. advice? thanks

here fiddle want ;)

https://jsfiddle.net/tkzr99vx/

it create div amount pass in createdivs method.

use rgb values did simpler code. still can use hex values have convert rgb.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -