MagTun
MagTun

Reputation: 6185

Display image on a gradient background on hover via css

I have this background:

.background:hover {
    background: #F4F4F4 url(../images/arrow_down_over.gif) no-repeat right;
}

that I would like to change into a gradient like this one :

    .background:hover{
        background: -moz-linear-gradient(top,  #f4f4f4 0%, #eeeeee 100%); /* FF3.6+ */
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f4f4f4), color-stop(100%,#eeeeee)); /* Chrome,Safari4+ */
        background: -webkit-linear-gradient(top,  #f4f4f4 0%,#eeeeee 100%); /* Chrome10+,Safari5.1+ */
        background: -o-linear-gradient(top,  #f4f4f4 0%,#eeeeee 100%); /* Opera 11.10+ */
        background: -ms-linear-gradient(top,  #f4f4f4 0%,#eeeeee 100%); /* IE10+ */
        background: linear-gradient(to bottom,  #f4f4f4 0%,#eeeeee 100%); /* W3C */
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee',GradientType=0 );
} /* IE6-9 */

But I would like to keep the arrow image. I can't find a way to do it. I did try something like this:

background: -moz-linear-gradient(top,  #f4f4f4 0%, #eeeeee 100%) url(../images/arrow_down_over.gif) no-repeat right; /* FF3.6+ */

or add this after the gradient properties but without any success.

 background: url(../images/arrow_down_over.gif) no-repeat right;

I can't add another class so I have to deal with this CSS. Any idea how to do it?

Upvotes: 0

Views: 1884

Answers (1)

jcaron
jcaron

Reputation: 17710

You may try:

background: url(../images/arrow_down_over.gif), linear-gradient(...);

Multiple backgrounds must be comma-separated rather than space-separated, and they weirdly stack from top to bottom.

Also note that this is not necessarily supported by all browsers.

See http://css-tricks.com/stacking-order-of-multiple-backgrounds/ and https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_multiple_backgrounds for details

Upvotes: 2

Related Questions