0

我是 html 和 css 的新手。这是我的CSS代码:

background: -moz-linear-gradient(center top, #F9F9F9, #F0F0F0) repeat scroll 0 0 rgba(0, 0, 0, 0);

此背景颜色效果在 IE 和 Chrome 中不起作用如何更改此代码以使其正常工作。

4

6 回答 6

2

渐变不再需要供应商前缀。

background: linear-gradient(to bottom, #F9F9F9, #F0F0F0);

完毕。

于 2013-10-25T09:27:07.043 回答
1

-moz-前缀仅由 Firefox 使用 - 因此您需要复制要在其他浏览器系列中使用的确切行:

background: linear-gradient(center top, #F9F9F9, #F0F0F0) repeat scroll 0 0 rgba(0, 0, 0, 0);
background: -webkit-linear-gradient(center top, #F9F9F9, #F0F0F0) repeat scroll 0 0 rgba(0, 0, 0, 0);
background: -o-linear-gradient(center top, #F9F9F9, #F0F0F0) repeat scroll 0 0 rgba(0, 0, 0, 0);
于 2013-10-25T09:27:45.340 回答
0

-moz-linear-gradient适用于 Mozilla 浏览器 (Firefox)。你应该使用webkit-linear-gradient铬。

于 2013-10-25T09:29:05.270 回答
0

-moz 是 Mozilla Firefox 的前缀,请查看此站点: http ://colorzilla.com/gradient-editor/ 并查看代码和注释:

background: #1e5799; /* Old browsers */  
background: -moz-linear-gradient(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Opera 11.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 */
于 2013-10-25T09:29:15.733 回答
0

你只为 Mozilla 做渐变,你需要分别为 IE 和 Chrome 做

请查看此站点,因为它会为您编写代码,但请提供评论,以便您了解每个浏览器如何响应每一行代码

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

示例代码

background: #1e5799; /* Old browsers */
background: -moz-linear-gradient(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Opera 11.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-9 */
于 2013-10-25T09:25:59.590 回答
0

检查文档https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient。这取决于浏览器使用的 javascript 引擎。

正如它所说的跨浏览器文档:

.grad { 
    background-color: #F07575; /* fallback color if gradients are not supported */
    background-image: -webkit-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For Chrome and Safari */
    background-image:    -moz-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For old Fx (3.6 to 15) */
    background-image:     -ms-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For pre-releases of IE 10*/
    background-image:      -o-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For old Opera (11.1 to 12.0) */ 
    background-image:         linear-gradient(to bottom, hsl(0, 80%, 70%), #bada55); /* Standard syntax; must be last */

}

于 2013-10-25T09:26:39.817 回答