简体   繁体   English

使用背景图像和css3渐变

[英]Using background image along with css3 gradients

I'm unable to use background image along with the css3 gradient. 我无法使用背景图像和css3渐变。 I've gone through many solutions but i'm still unable to get the image. 我已经经历了很多解决方案,但我仍然无法获得图像。 My Fiddle 我的小提琴

Here's the image 这是图像

Image used is transparent.I've tried adding background-image: url("img.png"), -webkit .. but this doesn't seem to work.Also tried having a div in below manner .. 使用的图像是透明的。我尝试添加background-image:url(“img.png”), - webkit ..但这似乎不起作用。也试过在下面的方式有一个div ..

<div id="div-with-gradient">
   <div id="div-with-image">
    <!-- content -->
    </div>
</div>

Any solutions really appreciated.. 任何解决方案真的很赞

You might want to check this demo I did last week http://dabblet.com/gist/3106299 您可能想查看我上周做过的演示http://dabblet.com/gist/3106299

It uses an image and a CSS3 gradient on the same element. 它在同一元素上使用图像和CSS3渐变。


Regarding your fiddle, url('../img/msg_arrow.png') won't work in jsFiddle - you need to specify the full path. 关于你的小提琴, url('../img/msg_arrow.png')在jsFiddle中不起作用 - 你需要指定完整路径。

Also, you are overriding your style with 而且,你用你的风格压倒一切

.btn1 {
    background-color: #f47e29;
    border: solid 1px #b16127;
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f48c41', endColorstr='#d66f24',GradientType=0 ); /* IE6-8 */
    padding: 0 26px;
}

which sets the solid orange background. 它设置了纯橙色背景。

And another thing I've noticed just now: the use of background-image isn't right either: 还有我刚才注意到的另一件事: background-image的使用也不对:

background-image: url('../img/msg_arrow.png') scroll 0 0 no-repeat, linear-gradient(bottom, #000000, rgba(0,0,0,.12) 0%, rgba(0,0,0,.12) 49%, rgba(72,72,72,.12) 50%, rgba(247,245,245,.12));

You need to use background there instead of background-image . 你需要在那里使用background而不是background-image

Finally, one more thing to note is that backgrounds are displayed stacked one on top of another and the last background listed is the one at the bottom of the stack. 最后,需要注意的另一件事是背景显示为堆叠在另一个之上, 最后列出的背景是堆栈底部背景 In your case, it is the gradient that is displayed behind the semitransparent image. 在您的情况下,它是在半透明图像后面显示的渐变。 And since your gradient is made up of colours having a 0.12 fourth RGBa value (alpha), which is very low, it may be very difficult to spot behind another image, even when everything is working fine. 而且由于渐变是由具有0.12第四RGBa值(alpha)的颜色组成的,这非常低,即使一切正常也可能很难在另一个图像后面发现。

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

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