Question

Multiple css selectors for a badge

  • 11 April 2024
  • 3 replies
  • 23 views

We are trying to place a badge for an engagement next to an image in our header (the same image, same location). The only issue is the selector name is different in a few places.

Is there a way to use more than one selector in the field below?

 


3 replies

Userlevel 3
Badge +1

It is often possible to use a comma as an OR operator to solve this kind of problem, e.g. “.imageClass1,.imageClass2”

 

If that doesn’t work in this instance, you can try inspecting the two selectors for any common traits that would allow you to use other operators like ‘contains’ or ‘ends in’ to find something sufficient to work in both cases. There’s a good reference for those selectors at https://www.w3schools.com/cssref/css_selectors.php

Userlevel 3

@rschlette 

We use a custom class to identify our targets - data-px

This requires us to define the items using

[data-px=”thing1”]

 

Would we be able to use something similar ?

like [data-px=”thing1”],[data-px=”thing2”]

or [data-px=”thing1”,data-px=”thing2”]

 

Userlevel 3
Badge +1

@lpicone Yes, the syntax [data-px=”thing1”],[data-px=”thing2”] will work the same way

Reply