So, I can see in CSS references how to set image transparency and how to set a background image. But how can I combine these two in order to set a transparent background image?
I have an image that I'd like to use as a background, but it is too bright - I'd like to turn the opacity down to about 0.2. How can I do this?
#main {
background-image: url(/wp-content/uploads/2010/11/tandem.jpg);
}
You can use CSS psuedo selector ::after to achieve this. Here is a working demo.
I have used the answer of @Dan Eastwell and it works very well. The code is similar to his code but with some additions.
Two methods:
<div>
that isposition: absolute;
before#main
and the same height as#main
, then apply the background-image andopacity: 0.2; filter: alpha(opacity=20);
.I had a similar issue and I just took the background image with photoshop and created a new .png with the opacity I needed. Problem solved without worrying about if my CSS worked accross all devices & browsers
Well the only CSS way of doing only background transparency is via
RGBa
but since you want to use an image I would suggest using Photoshop or Gimp to make the image transparent and then using it as the background.In your CSS add...
In JavaScript use...
NB: Add vendor prefixes as required but Chromium should be fine without.