0

我正在尝试在浏览器中使用线性背景渐变。它适用于 FF,但不适用于 Chrome。我的 CSS 如下所示:

  /* works in FF */

  background: -moz-linear-gradient(center top , rgb(40, 40, 40) 0px, rgb(10, 10, 10) 100%) repeat scroll 0% 0% transparent;


  /* Not working in chrome */
  background: -webkit-linear-gradient(center top , rgb(40, 40, 40) 0px, rgb(10, 10, 10) 100%) repeat scroll 0% 0% transparent;

怎么了?

4

1 回答 1

1

根据我的评论,将来使用Ultimate CSS Gradient Generator

您也可以上传自己的CSS来生成浏览器兼容性样式

从你的CSS

background: -moz-linear-gradient(center top , rgb(40, 40, 40) 0px, rgb(10, 10, 10) 100%) repeat scroll 0% 0% transparent;

生成器输出:

background: #282828; /* Old browsers */
background: -moz-linear-gradient(left, #282828 0px, #0a0a0a 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0px,#282828), color-stop(100%,#0a0a0a)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #282828 0px,#0a0a0a 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #282828 0px,#0a0a0a 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #282828 0px,#0a0a0a 100%); /* IE10+ */
background: linear-gradient(to right, #282828 0px,#0a0a0a 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#282828', endColorstr='#0a0a0a',GradientType=1 ); /* IE6-9 */

JSFiddle

于 2013-10-02T10:38:49.503 回答