Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS select elements with background-image set to specific url [duplicate]

I have element that I want to hide if the background-color property has specific url provided to it (namely default image - copied from HTML that I have no control over : style='background-image: url("assets/images/default_logo.png");')

Is there a way to query for this specific case with CSS?

Concrete example:

<div class="module-logo"
     ng-show="!show_loading &amp;&amp; module_logo != ''"
     style="background-image: url(&quot;assets/images/default_logo.png&quot;);"
     aria-hidden="false">
</div>
like image 406
zmii Avatar asked Aug 10 '17 13:08

zmii


1 Answers

Yes, you can select that div with this:

div[style^="background-image: url"]

It might require you to use CSS escape characters, which can get messy, so you can alternatively use two sets of selectors to check for the substrings that target exactly what you're looking for. Example of something that would work here:

div[style*="background-image: url("][style*="default_logo.png"]
like image 90
yoursweater Avatar answered Nov 15 '22 06:11

yoursweater