I have a Angular application where I display query results in a div (identified by the ID JSONContainer).
To emphasize specific queries within the results, I implemented a pipe that searches for and replaces FIELD:VALUE with:
<span class="highlightSpan">FIELD:VALUE</span>.
I included the following CSS in the component:
div#JSONContainer span.highlightSpan{
background-color: rgba(28, 243, 28, 0.5) !important;
color:red !important;
padding: 1px;
margin:1px;
}
I also tried adding the same style under .highlightSpan, but encountered the same issue.
The span along with the rest of the text is inserted via innerHTML using the 'data' variable, which holds the entire JSON, and the 'query' variable holding the query:
<div class="col-xs-12" id="JSONContainer"
[innerHTML]="data | textHighlight:query">
</div>
(I'm avoiding string interpolation as the data variable contains JSON formatted data styled with HTML code like
tags, and string interpolation displays just plain text.)
Upon inspecting the relevant span in Google Dev Tools, I confirmed that the span with the specified class was created:
https://i.sstatic.net/rWwkJ.jpg
However, the CSS styling is not being applied and doesn't even appear in Google Dev Tools:
https://i.sstatic.net/mAR6d.jpg
EDIT: Although it's not visible in the image, please note that the span is indeed located within the div#JSONContainr as mentioned.
EDIT 2: Here is the relevant tree structure:
https://i.sstatic.net/jvF7I.jpg
What could be causing this issue?
How can I ensure the CSS styles are successfully applied?
Thank you!