1

I used the Colorzilla CSS gradient generator to create a background that has multiple color stops. It works great in Firefox and Safari but in Chrome there is a subtle striping/banding thing going on that is frustrating. Here's my code and a jsfiddle link:

body {
background: rgb(0,0,0); /* Old browsers */
background: -moz-linear-gradient(left,  rgba(0,0,0,1) 0%, rgba(85,187,0,1) 15%, rgba(85,187,0,1) 25%, rgba(221,34,85,1) 45%, rgba(221,34,85,1) 55%, rgba(0,136,238,1) 75%, rgba(0,136,238,1) 85%, rgba(0,0,0,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(0,0,0,1)), color-stop(15%,rgba(85,187,0,1)), color-stop(25%,rgba(85,187,0,1)), color-stop(45%,rgba(221,34,85,1)), color-stop(55%,rgba(221,34,85,1)), color-stop(75%,rgba(0,136,238,1)), color-stop(85%,rgba(0,136,238,1)), color-stop(100%,rgba(0,0,0,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left,  rgba(0,0,0,1) 0%,rgba(85,187,0,1) 15%,rgba(85,187,0,1) 25%,rgba(221,34,85,1) 45%,rgba(221,34,85,1) 55%,rgba(0,136,238,1) 75%,rgba(0,136,238,1) 85%,rgba(0,0,0,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left,  rgba(0,0,0,1) 0%,rgba(85,187,0,1) 15%,rgba(85,187,0,1) 25%,rgba(221,34,85,1) 45%,rgba(221,34,85,1) 55%,rgba(0,136,238,1) 75%,rgba(0,136,238,1) 85%,rgba(0,0,0,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left,  rgba(0,0,0,1) 0%,rgba(85,187,0,1) 15%,rgba(85,187,0,1) 25%,rgba(221,34,85,1) 45%,rgba(221,34,85,1) 55%,rgba(0,136,238,1) 75%,rgba(0,136,238,1) 85%,rgba(0,0,0,1) 100%); /* IE10+ */
background: linear-gradient(to right,  rgba(0,0,0,1) 0%,rgba(85,187,0,1) 15%,rgba(85,187,0,1) 25%,rgba(221,34,85,1) 45%,rgba(221,34,85,1) 55%,rgba(0,136,238,1) 75%,rgba(0,136,238,1) 85%,rgba(0,0,0,1) 100%); /* W3C */
width:100%;
margin-bottom:1em;
}

http://jsfiddle.net/yL82a/ (ignore the margin-bottom declaration)

Any idea how to fix this in Chrome to just be a nice smooth gradient? I've tried this using both rgba and hex values and get the same result.

4

3 回答 3

1

我希望整个页面都有渐变背景,这个问题很烦人。-webkit-filter: blur(3px);最后我可以通过应用来去除条纹<body>,但是整个内容都变得模糊了,所以我做了一个单独<div>的作为页面的背景,并对其应用了过滤器。

CSS:

html, body {
   width: 100%;
   margin: 0;
}

#page-background
{
    width: 100%;
    height: 100%;
    background: #383838; /* Old browsers */
    background: -webkit-linear-gradient(top, #383838 0%,#d6d6d6 100%); /* Chrome10+,Safari5.1+ */
    (...)
    -webkit-filter: blur(3px);
}

HTML:

<body>
    <div id="page-background"></div>
    And content goes here...

渐变是在ColorZilla 站点生成的。

于 2014-01-18T18:34:37.623 回答
0

与 Chrome 如何处理抖动有关。此处讨论了问题:

https://graphicdesign.stackexchange.com/questions/8426/gradient-banding-in-chrome

于 2013-02-14T18:56:00.687 回答
-1

尝试从此站点生成 css 渐变,看看是否有任何差异,它将帮助您调试代码,

http://ie.microsoft.com/testdrive/graphics/cssgradientbackgroundmaker/default.html

祝你好运。。

于 2013-02-14T17:49:38.653 回答