简体   繁体   English

CSS3背景:重复线性渐变

[英]CSS3 background: repeating-linear-gradient

A couple of days ago I read this article: http://tutorialzine.com/2013/10/12-awesome-css3-features-you-can-finally-use/ 几天前,我读了这篇文章: http : //tutorialzine.com/2013/10/12-awesome-css3-features-you-can-finally-use/

and found about the new CSS3 syntax repeating-linear-gradient . 并发现了有关新CSS3语法repeating-linear-gradient

So far it only works in FireFox, even though I use prefixes. 到目前为止,即使我使用前缀,它也只能在FireFox中使用。

background: #000;
background-image: -webkit-repeating-linear-gradient(-45deg, black, black, #2a2a2a 6px, #2a2a2a 6px);
background-image: -moz-repeating-linear-gradient(-45deg, black, black, #2a2a2a 6px, #2a2a2a 6px);
background-image: -ms-repeating-linear-gradient(-45deg, black, black, #2a2a2a 6px, #2a2a2a 6px);
background-image: -o-repeating-linear-gradient(-45deg, black, black, #2a2a2a 6px, #2a2a2a 6px);
background-image: repeating-linear-gradient(-45deg, black, black, #2a2a2a 6px, #2a2a2a 6px);

I have the latest versions of Google Chrome( Version 30.0.1599.101 m ) and IE( v9.0.8112.16421 ). 我拥有最新版本的Google Chrome( Version 30.0.1599.101 m )和IE( v9.0.8112.16421 )。 I cannot update IE to a higher version, because of some company policies. 由于某些公司政策,我无法将IE更新到更高版本。

Am I doing something wrong? 难道我做错了什么?

This is my fiddle 这是我的小提琴

Your example does work here in Firefox (20.0) and Chromium (25.0.1364.160). 您的示例在Firefox(20.0)和Chromium(25.0.1364.160)中确实适用。 I adapted the example from MDN - repeating-linear-gradient . 我改编自MDN-重复线性梯度 I only added a width and height 我只加了一个宽度和高度

#grad3 {
    width: 100px;
    height: 100px;
}

See JSFiddle 参见JSFiddle

When you change one of the black colors, you will see the pattern better, see modified JSFiddle . 当您更改一种黑色时,您会看到更好的图案,请参阅修改后的JSFiddle

for IE 8,10 can use: 对于IE 8,10,可以使用:

background: -ms-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* IE10+ */
background: linear-gradient(to bottom, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-8 */

IE9 not support CSS Gradiant, http://css3wizardry.com/2010/10/29/css-gradients-for-ie9/ i recommend ussing -pie-gradiant for the issue in IE9: http://css3pie.com/documentation/supported-css3-features/ IE9不支持CSS Gradiant, http: //css3wizardry.com/2010/10/29/css-gradients-for-ie9/对于IE9中的问题,我建议使用-pie-gradiant: http ://css3pie.com/documentation /支持,CSS3的功能/

also you can use http://www.colorzilla.com/gradient-editor/ for better result, 您也可以使用http://www.colorzilla.com/gradient-editor/获得更好的结果,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM