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

WBOY
Release: 2016-06-24 11:47:44
Original
3416 people have browsed it

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template