开发者

What is the easiest cross-browser compatible way of creating gradients with CSS?

I noticed this being used by a service, and the effect looks super great

-moz-linear-gradient(center top ,开发者_StackOverflow社区 #E3EBF3, #D5E1ED) repeat scroll 0 0 transparent


Use the CSS property like you have in your question. Add the -moz, -webkit prefixes, then use it prefixless.

IE's filter property can do gradients. It is propriety, but it works :)


http://www.colorzilla.com/gradient-editor/

use modernizr and some if IE blocks at the top to add classes to your html tag so that you can provide valid HTML and CSS, and hacks&properties to those necessary.

for instance, in a gradient I've used in the past:

body {
background: #2688cf;
}
.cssgradients body{
background: -moz-linear-gradient(top, #2688cf 0%, #2989d8 12%, #207cca 14%, #62a2d6 18%, #b9d5ea 28%, #ffffff 40%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2688cf), color-stop(12%,#2989d8), color-stop(14%,#207cca), color-stop(18%,#62a2d6), color-stop(28%,#b9d5ea), color-stop(40%,#ffffff));
background: -webkit-linear-gradient(top, #2688cf 0%,#2989d8 12%,#207cca 14%,#62a2d6 18%,#b9d5ea 28%,#ffffff 40%);
background: -o-linear-gradient(top, #2688cf 0%,#2989d8 12%,#207cca 14%,#62a2d6 18%,#b9d5ea 28%,#ffffff 40%);
background: linear-gradient(top, #2688cf 0%,#2989d8 12%,#207cca 14%,#62a2d6 18%,#b9d5ea 28%,#ffffff 40%);
}

.ie6 body, .ie7 body, .ie8 body, .ie9 body {
background: -ms-linear-gradient(top, #2688cf 0%,#2989d8 12%,#207cca 14%,#62a2d6 18%,#b9d5ea 28%,#ffffff 40%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2688cf', endColorstr='#ffffff',GradientType=0 );
background: linear-gradient(top, #2688cf 0%,#2989d8 12%,#207cca 14%,#62a2d6 18%,#b9d5ea 28%,#ffffff 40%);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜