I'm trying to set a linear-gradient on a div from red to transparent, but the output is a bit strange: fiddle.

Fiddle's css:

background: -webkit-linear-gradient(transparent, red);
background:    -moz-linear-gradient(transparent, red);
background:     -ms-linear-gradient(transparent, red);
background:      -o-linear-gradient(transparent, red);
background:         linear-gradient(transparent, red);

As you can see, the transition between the two colors is in gray, while I expected only a red gradation.

Does anybody know how to improve this output (without replacing "transparent" by "yellow" in the fiddle)?

PS: tried in Chrome 23.0.1271.64

有帮助吗?

解决方案

try changing transparent into rgba(255,0,0, 0)

example fiddle: http://jsfiddle.net/9MpNM/

其他提示

I have just modified your jsfiddle

Check if like you want

background: -webkit-linear-gradient(rgba(255,0,0,1) 0%,rgba(255,255,255,0) 100%);
background:    -moz-linear-gradient(rgba(255,0,0,1) 0%,rgba(255,255,255,0) 100%);
background:     -ms-linear-gradient(rgba(255,0,0,1) 0%,rgba(255,255,255,0) 100%);
background:      -o-linear-gradient(rgba(255,0,0,1) 0%,rgba(255,255,255,0) 100%);
background:         linear-gradient(rgba(255,0,0,1) 0%,rgba(255,255,255,0) 100%);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top