背景渐变不工作在chrome(在Firefox中工作)

时间:2013-10-02 10:20:41

标签: html css

我想在浏览器中设置线性背景渐变。它适用于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;

有什么问题?

1 个答案:

答案 0 :(得分: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