基于通配符的属性名称的CSS选择器 [英] CSS selector for attribute names based on a wildcard
问题描述
我最近一直在对CSS选择器进行一些研究,并遇到关于新的data- *属性的问题。
I've recently been doing a little studying on CSS selectors and have run into a question regarding the new "data-*" attributes.
我理解为了选择具有数据属性的元素,有几种方法来处理:
I understand that in order to select elements with a data attribute there are a few ways of going about it:
[data-something='value']{...} // data-something has value = 'value'
[data-something^='value']{...} // data-something has value that STARTS with 'value'
[data-something*='value']{...} // data-something has value with 'value SOMEWHERE in it
这些还有其他变体,但我的问题是CSS选择器可以针对的元素,只有一个数据属性。更具体地说,是否有一个CSS选择器可以针对具有任何数据属性的元素?
There are other variations of these, but my question pertains to CSS selectors that can target elements that simply HAVE a "data" attribute. More specifically, is there a CSS selector that can target elements that have ANY "data" attribute at all?
虽然不正确,但我想到的是: p>
While incorrect, I'm thinking of something like:
[data]{...}
我一直在搜索谷歌,但还没有找到任何关于属性的通用选择器。
I've been searching through Google but haven't found anything regarding a generic selector for the attribute yet.
推荐答案
否,CSS选择器中的属性名称没有通配符。所有属性选择器都禁止某个属性的特定名称。
No, there is no wildcarding for attribute names in CSS selectors. All attribute selectors contrain a specific name of an attribute.
这篇关于基于通配符的属性名称的CSS选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!