css选择器以匹配没有属性x的元素
我正在处理CSS文件,发现需要设置文本输入框的样式,但是,我遇到了问题。我需要一个匹配所有这些元素的简单声明:
<input /><input type='text' />
<input type='password' />
…但不符合以下条件:
<input type='submit' /><input type='button' />
<input type='image' />
<input type='file' />
<input type='checkbox' />
<input type='radio' />
<input type='reset' />
这是我想做的:
input[!type], input[type='text'], input[type='password'] { /* styles here */
}
在上述CSS中,请注意第一个选择器是input[!type]
。我的意思是我要选择未指定type属性的所有输入框(因为它默认为文本,但input[type='text']
不匹配)。不幸的是,我找不到CSS3规范中的此类选择器。
有人知道实现此目标的方法吗?
回答:
选择器
input:not([type]), input[type='text'], input[type='password'] { /* style here */
}
以上是 css选择器以匹配没有属性x的元素 的全部内容, 来源链接: utcz.com/qa/412555.html