Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding images when CSS gradients are used?

Tags:

html

css

I am trying to create a button using CSS Gradients plus a icon that goes on top of the gradient. I tried 2 ways and both was a failure.

First:

.btn {
    background: -webkit-gradient(linear, 0% 0%, 0% 89%, from(#3171CA), to(#15396F));
    background: url(../images/btn.png);
}

I should of knew that wouldn't of worked! But I also heard about CSS3 multiple background images, so I tried it that way.

Second:

.btn {
        background: -webkit-gradient(linear, 0% 0%, 0% 89%, from(#3171CA), to(#15396F)), url(../images/btn.png);
    }

Still didn't work :(. Is there any way to actually do this? With adding a <img> tag in the <button>?

like image 580
omnix Avatar asked Aug 24 '10 05:08

omnix


People also ask

How do you apply a gradient to an image in CSS?

To create a linear gradient you must define at least two color stops. Color stops are the colors you want to render smooth transitions among. You can also set a starting point and a direction (or an angle) along with the gradient effect.

How do I combine a background image and CSS3 gradient on the same element?

You can combine a background-image and CSS3 gradient on the same element by using several backgrounds. In our example below, we set the height and width of our <div> and add a background. Then, we set the background image fallback using the “url” value of the background-image property.

How do I combine background and image images in CSS?

Use background-blend-mode and rgba to mix the background image and color. If you adjust the alpha value of the rgba color value (it's at . 85 in the example), you can control the transparency. Also, background-blend-mode has other values you can play with to get some really creative results.

How do you overlay images in CSS?

In short, CSS overlay effects are achieved by using the following: background-image and background CSS properties to add image and linear-gradient overlay effect. position:absolute , top , bottom , right , left CSS properties to control the position of overlay image or text.


1 Answers

only webkit browsers allow multiple background effects (CSS3) .. generally speaking you can have a gradient OR and image but you can't have both (yet)

you could overlay 2 divs tho and have the image for the topmost be transparent PNG or such

like image 110
Scott Evernden Avatar answered Sep 26 '22 01:09

Scott Evernden