将彩色图像png转换为彩色css渐变

时间:2016-05-25 08:21:44

标签: css png

我想将此PNG图像转换为CSS渐变颜色。如果我有这个PNG文件,我怎么能这样做?

Image used for header with repeat-x

1 个答案:

答案 0 :(得分:0)

只需使用渐变CSS规则吗?

#grad {
    background: linear-gradient(black, white); /* Standard syntax */
}

#grad2 {
  background: red; /* For browsers that do not support gradients */
  background: -webkit-linear-gradient(red, yellow, green); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(red, yellow, green); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(red, yellow, green); /* For Firefox 3.6 to 15 */
  background: linear-gradient(red, yellow, green); /* Standard syntax */
}
<div id="grad">
  <br><br>
</div>

<div id="grad2">
  <br><br>
</div>

一些阅读:CSS Gradients