Home  >  Article  >  Web Front-end  >  CSS 如何实现颜色从黑到白的渐变?_html/css_WEB-ITnose

CSS 如何实现颜色从黑到白的渐变?_html/css_WEB-ITnose

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

有一个数组,数值值在0到50之间,现在想0的时候颜色是白色,50的时候颜色是黑色,这个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>");}

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