Is there a CSS selector by class prefix?

后端 未结 4 543
终归单人心
终归单人心 2020-11-22 05:08

I want to apply a CSS rule to any element whose one of the classes matches specified prefix.

E.g. I want a rule that will apply to div that has class that starts wit

4条回答
  •  名媛妹妹
    2020-11-22 05:34

    You can't do this no. There is one attribute selector that matches exactly or partial until a - sign, but it wouldn't work here because you have multiple attributes. If the class name you are looking for would always be first, you could do this:

    
    
    Test Page
    
    
    
    
    A
    B
    C

    Note that this is just to point out which CSS attribute selector is the closest, it is not recommended to assume class names will always be in front since javascript could manipulate the attribute.

提交回复
热议问题