Opacity | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Opacity

Does this also work with borders and text or just images?

28th Aug 2019, 1:51 AM
Andrew Johnson
Andrew Johnson - avatar
2 Answers
+ 4
The opacity property applies to full elements - You can use it on divs, paragraphs, etc. However, borders are part of an element, so applying opacity on that element would not only affect the border but also the element. The workaround would be to use rgba as part of the border definition. border: 5px solid rgba(255, 0, 0, 0.5); This would set the border at 50% opacity.
28th Aug 2019, 2:09 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
Yes, it is work for all the elements. You can see some examples here, https://www.w3schools.com/cssref/css3_pr_opacity.asp Good Luck~
28th Aug 2019, 2:18 AM
Uchiha Itachi
Uchiha Itachi - avatar