Posted By: Anonymous
Can I assign the
opacity property to the
background property of a
div only and not to the text on it?
background: #CCC; opacity: 0.6;
but this doesn’t change the opacity.
It sounds like you want to use a transparent background, in which case you could try using the
rgba(R, G, B, A)
R (red), G (green), and B (blue) can be either
<percentage>s, where the number 255 corresponds to 100%. A (alpha) can be a
<number>between 0 and 1, or a
<percentage>, where the number 1 corresponds to 100% (full opacity).
rgba(51, 170, 51, .1) /* 10% opaque green */ rgba(51, 170, 51, .4) /* 40% opaque green */ rgba(51, 170, 51, .7) /* 70% opaque green */ rgba(51, 170, 51, 1) /* full opaque green */
A small example showing how
rgba can be used.
As of 2018, practically every browser supports the