Home >Web Front-end >HTML Tutorial >How to achieve color gradient from black to white in CSS? _html/css_WEB-ITnose

How to achieve color gradient from black to white in CSS? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:47:443448browse

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?


Reply to discussion (solution)

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>");}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn