Succinct way of specifying two or more values for an attribute in css selector

后端 未结 2 1364
囚心锁ツ
囚心锁ツ 2021-01-23 14:31

I have a CSS selector as follows:

#foo input[type=number].form-control, #foo input[type=text].form-control
2条回答
  •  时光取名叫无心
    2021-01-23 14:43

    No, I'm afraid there isn't. While there are no proposals for enumerated values in attribute selectors like the one in your example, Selectors 4's :matches() will at least allow you to OR two attribute selectors in a single compound selector:

    #foo input:matches([type=number], [type=text]).form-control
    

    That said, you will probably have to stick with the current, verbose syntax for the foreseeable future, until browsers start implementing :matches().

提交回复
热议问题