: Using Opacity of a Div without affecting The color of the Paragraph inside the Div I have created a div with background color black, and written a p inside it with white. When I am using
I have created a div with background color black, and written a p inside it with white. When I am using opacity in the div, the color of the p is also getting changed into gray. Is there any way to change the opacity only of the div without affecting the color of the p?
More posts by @Jamie315
2 Comments
Sorted by latest first Latest Oldest Best
You can use css :after selector to give shadow dom element the background color and opacity. This will not effect to p tag.
Here is jsfiddle jsfiddle.net/vjandrei/fyvc3ejy/2/
Just read this article. It explains everything: css-tricks.com/rgba-browser-support/
You should have:
div {
background: rgba(0, 0, 0, 0.5);
color: #fff ;
}
There are also same or similar questions here, like this: stackoverflow.com/questions/15449280/html-css-text-background-transparent-but-text-not
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.