基本的选择器规则(Selector) 类型(Type)选择器 类(Class)选择器 ID 选择器 参数(Attribute)选择器 通配符 组合选择器(Combinator) 子选择器和后代选择器 兄弟选择器和相邻兄弟选择器 选择器列表 伪类(Pseudo-Classes) 链接和按钮相关 表单输入相关 DOM 子节点相关 DOM 相关的其他伪类 其他 伪元素(Pseudo-ele
CSS [attribute~="value"] Selector The[attribute~="value"]selector is used to select elements with an attribute value containing a specified word. The following example selects all elements with a title attribute that contains a space-separated list of words, one of which is "flower": ...
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference#Selectors 在css3规范中,定义了以下几种类型的selector: Basic selector type selector: elementname class selector: .classname ID selector: #idName universal selector: * ns|* *|* attribute selector [attr=value] Combinators adjacent sib...
CSS [attribute|="value"] Selector The[attribute|="value"]selector is used to select elements with the specified attribute, whose value can be exactly the specified value, or the specified value followed by a hyphen (-). Note:The value has to be a whole word, either alone, like class=...
CSS Selector 之 Attribute Selector 这个从名字上就很好理解,即根据属性来选择元素。 举几个例子: input[type="password"] input[type] /* 有 type 属性的 input */ 当然,也支持复杂的正则方式匹配 a[href$=".pdf"] 即,属性 href 以 .pdf 为结尾的 a 标签。
Selector [attribute=value]4.07.02.03.19.6 CSS Syntax [attribute=value] { css declarations; }Demo More Examples Example Set the width of an <input type="text"> element to 100px. However, when it gets focus, make it 250px wide:
CSS Case Insensitive Attribute Selector All In One CSS大小写敏感的属性选择器 Adding aspacebefore theiflag to the attribute selector brackets will make the attribute value searchcase insensitive. demos bug 🐞 https://github.com/mdn/content/blob/main/files/en-us/web/css/attribute_selectors/index...
Selector [attribute] 4.0 7.0 2.0 3.1 9.6Note: For [attribute] to work in IE8 and earlier, a <!DOCTYPE> must be declared.CSS Syntax[attribute] { css declarations;} Demo Related PagesCSS tutorial: CSS Attribute Selectors« Previous CSS Selectors Reference Next » ...
:not(selector):选中不匹配给定选择器的元素。例如,div:not(.active)选中所有没有.active类的<div>元素。特殊状态选择器::empty:选中没有任何子元素(包括文本节点)的元素。:target:选中URL中指定id的元素。例如,如果URL是http://example.com/#section1,则:target会选中id为section1的元素。
使用[attribute$=value] 来选择具有指定属性,并且该属性的值以给定值结尾的元素。 伪类 链接伪类选择器 这4 个伪类用于选择链接处于不同状态的元素。它们最常与链接一起使用,但是:active也适用于按钮,而:hover可以用于各种元素: :link:选取未被访问过的链接,用于为用户尚未点击的超链接设置样式。