Similar question to How do I overlay a gradient background over an existing background with CSS? and of course How do I combine a background-image and CSS3 gradient on the same element?, but in this case I do not have control over the background image URL.
Case in point
As part of some styling I was implementing to improve my Facebook experience, I wrote this piece of CSS:
.jewelCount > span { /* replaces notification color with a more neutral tone of red */
background-color: #ab5151;
}
.jewelButton > div { /* adds a faint overlay on top of notification icons to achieve a more neutral shade of white */
background-image: linear-gradient(rgba(66, 103, 178, 0.1), rgba(66, 103, 178, 0.1)), url(/rsrc.php/v3/yc/r/rZKhvPo9Lsv.png) !important;
}
(using the Stylish extension for Firefox).
and it works,
but in the meantime, the background image URL changed from /rsrc.php/v3/yc/r/rZKhvPo9Lsv.png
to /rsrc.php/v3/y1/r/vZXeFuzjfGs.png
and I had to update my style manually, which sucks.
Since I'm not changing the background image's url()
at all (I'm only reusing it in the background-image
property to achieve the overlay effect), is there a way to "preppend" the linear-gradient
function to whatever background-image
is already in use for that element?
If it's not possible in CSS (and I'm guessing it's not), I'll settle with a solution using javascript for use with Greasemonkey (no jQuery, though).
Thanks.