gpt4 book ai didi

css - 这两个使用 “:not” 的选择器有什么区别?

转载 作者:技术小花猫 更新时间:2023-10-29 11:02:26 25 4
gpt4 key购买 nike

这两个选择器有什么区别?

input:not([type="radio"][type="submit"])
input:not([type="radio"]):not([type="submit"])

请问 <input>没有 type 的标签选择属性?

我读过:

最佳答案

引用 the Selector Level 4 docs :

The negation pseudo-class, :not(), is a functional pseudo-class taking a selector list as an argument. It represents an element that is not represented by its argument.

Note: In Selectors Level 3, only a single simple selector was allowed as the argument to :not().

这就解释了为什么这......

input:not([type="radio"][type="submit"])

... 在任何不实现这部分 CSS4 规范的浏览器中都不支持(据我所知,目前还没有人这样做;毕竟它只是一个工作草案)。但是这个选择器的逻辑也有缺陷:即使语法得到普遍支持,它也应该写成...

input:not([type="radio"],[type="submit"])

请参阅,[foo][bar] 规则被视为要求任何元素都 foobar。但是(当然!)任何输入都不可能同时是 radiosubmit 类型。

底线:你必须使用...

input:not([type="radio"]):not([type="submit"])

...因为CSS3 only supports simple selectors:not.

关于css - 这两个使用 “:not” 的选择器有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33012862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com