2012-10-25 60 views
2

我该怎么做? 我有什么是这些图像和这些gradiente,但我只显示梯度,而不是两个。Css使用透明图像和渐变背景

div { 
    background: url(/Icons/icon.png) no-repeat; 
    background-image: -moz-linear-gradient(top, #a2a2a2, #878787); 
    background-image: -ms-linear-gradient(top, #a2a2a2, #878787); 
    background-image: -o-linear-gradient(top, #a2a2a2, #878787); 
    background-image: -webkit-linear-gradient(top, #a2a2a2, #878787); 
    background-image: linear-gradient(top, #a2a2a2, #878787); 
} 
+1

尝试改变“背景图片”,只是“背景” – jtheman

+0

我不能等到我们能够停止使用供应商前缀。 – Shmiddty

回答

1

听起来像你想要多个背景图像。从逻辑上讲,它可能看起来像一个渐变背景颜色,但浏览器将渐变信息视为背景图像。

试着这么做:

div{ 
    background-image: -moz-linear-gradient(top, #a2a2a2, #878787), url(/Icons/icon.png); 
    background-image: -ms-linear-gradient(top, #a2a2a2, #878787), url(/Icons/icon.png); 
    background-image: -o-linear-gradient(top, #a2a2a2, #878787), url(/Icons/icon.png); 
    background-image: -webkit-linear-gradient(top, #a2a2a2, #878787), url(/Icons/icon.png); 
    background-image: linear-gradient(top, #a2a2a2, #878787), url(/Icons/icon.png); 
    background-repeat: no-repeat, no-repeat; 
} 
+0

这是因为渐变被定义为spec中的图像值:http://www.w3.org/TR/css3-images/#gradients – BoltClock

+0

知识!谢谢 :) – chrisgonzalez