I have a DIV and I would like to put a pattern as background. This pattern is gray. So to make it a little more nice, I would like to put a light transparent color "layer" over. Below is what I tried but which did not work. Is there a way to put the colored layer over the background image?
Here's my CSS:
background: url('../img/bg/diagonalnoise.png');
background-color: rgba(248, 247, 216, 0.7);
I know this is a really old thread, but it shows up at the top in Google, so here's another option.
This one is pure CSS, and doesn't require any extra HTML.
There are a surprising number of uses for the box-shadow feature.
You need then a wrapping element with the bg image and in it the content element with the bg color:
and the css:
Why so complicated? Your solution was almost right except it's a way easier to make the pattern transparent and the background color solid. PNG can contain transparencies. So use photoshop to make the pattern transparent by setting the layer to 70% and resaving your image. Then you only need one selector. Works cross browser.
CSS:
HTML:
Here it is:
HTML for this:
Of course you need to define a width and height to the
.background
class, if there are no other elements inside of itYou can also use a linear gradient and an image: http://codepen.io/anon/pen/RPweox
This is because the linear gradient function creates an Image which is added to the background stack. https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient
Here is a more simple trick with only css.