css中的对角渐变

时间:2013-08-15 05:10:46

标签: css

我见过的大部分渐变都是垂直或水平的。是否可以使用css进行对角线渐变?我希望有一个渐变,在一个角落开始变暗,在对角变亮。

3 个答案:

答案 0 :(得分:2)

是。 http://www.colorzilla.com/gradient-editor/可以选择对角线,查看方向。

答案 1 :(得分:2)

background: -moz-linear-gradient(-45deg,  rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,rgba(0,0,0,0.65)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(-45deg,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(-45deg,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(-45deg,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%); /* IE10+ */
    background: linear-gradient(135deg,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6000000', endColorstr='#00000000',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */

http://jsfiddle.net/jrc72/show

答案 2 :(得分:1)

请参阅此演示http://jsfiddle.net/FQSdb/

并查看http://www.colorzilla.com/gradient-editor/各种方向选项