缺少属性的元素是否有CSS选择器? [英] Is there a CSS selector for elements lacking an attribute?
本文介绍了缺少属性的元素是否有CSS选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我了解CSS规则可以定位由属性值指定的元素,例如:
I understand that css rules can target elements specified by attribute values, e.g.:
input[type="text"] {}
我可以制定一个规则来定位省略某个属性的元素吗?例如,我可以定位缺少href的元素还是不指定类型的元素吗?
Can I make a rule that targets elements which omit a certain attribute? For example, can I target elements that lack an href or elements that don't specify a type?
推荐答案
您可以遵循以下模式:
a:not([href])
input:not([type])
属性选择器用于选择具有指定属性的元素.
The attribute selector is used to select elements with the specified attribute.
:not
或更低的支持水平,您就没运气了.
:not
is supported in all modern browsers and IE9+, if you need IE8 or lower support you're out of luck.
这篇关于缺少属性的元素是否有CSS选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文