Home >Web Front-end >HTML Tutorial >How to achieve color gradient from black to white in CSS? _html/css_WEB-ITnose
There is an array with numerical values between 0 and 50. Now I want the color to be white when it is 0 and black when it is 50. How should I write this css?
for (var i=0; i<=50; i++){ var color = Math.round(255-255/50*i); document.write("<div style='height: 10px; background: rgb(",color,",",color,",",color,");'></div>");}