wildcard * in CSS for classes

前端 未结 4 1956
忘掉有多难
忘掉有多难 2020-11-22 10:58

I have these divs that I\'m styling with .tocolor, but I also need the unique identifier 1,2,3,4 etc. so I\'m adding that it as another class tocolor-1

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 11:39

    An alternative solution:

    div[class|='tocolor'] will match for values of the "class" attribute that begin with "tocolor-", including "tocolor-1", "tocolor-2", etc.

    Beware that this won't match

    Reference: https://www.w3.org/TR/css3-selectors/#attribute-representation

    [att|=val]

    Represents an element with the att attribute, its value either being exactly "val" or beginning with "val" immediately followed by "-" (U+002D)

提交回复
热议问题