简体   繁体   English

具有透明图像和渐变的CSS背景

[英]Css Background with a transparent image and a gradient

How can I do it? 我该怎么做? What I have is these image and these gradiente but i's only showing the gradient and not both. 我所拥有的是这些图像和这些gradiente,但我仅显示了渐变,而不是两者都显示。

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);
}

Sounds like you want multiple background images. 听起来好像您想要多个背景图像。 Logically it may seem like a gradient is a background color, but browsers treat Gradient information like a background image. 从逻辑上讲,似乎渐变是背景色,但浏览器将“渐变”信息视为背景图像。

Try something like: 尝试类似:

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM