Is there a CSS selector for elements containing certain text?

后端 未结 18 2364
别跟我提以往
别跟我提以往 2020-11-21 04:26

I am looking for a CSS selector for the following table:

Peter    | male    | 34
Susanne  | female  | 12

Is there any selector to match all

18条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 05:08

    I agree the data attribute (voyager's answer) is how it should be handled, BUT, CSS rules like:

    td.male { color: blue; }
    td.female { color: pink; }
    

    can often be much easier to set up, especially with client-side libs like angularjs which could be as simple as:

    
    

    Just make sure that the content is only one word! Or you could even map to different CSS class names with:

    
    

    For completeness, here's the data attribute approach:

    
    

提交回复
热议问题