相关疑难解决方法(0)

css选择器匹配没有属性x的元素

我正在研究CSS文件并发现需要设置文本输入框的样式,但是,我遇到了问题.我需要一个匹配所有这些元素的简单声明:

<input />
<input type='text' />
<input type='password' />
Run Code Online (Sandbox Code Playgroud)

......但不符合这些:

<input type='submit' />
<input type='button' />
<input type='image' />
<input type='file' />
<input type='checkbox' />
<input type='radio' />
<input type='reset' />
Run Code Online (Sandbox Code Playgroud)

这就是我想做的事情:

input[!type], input[type='text'], input[type='password'] {
   /* styles here */
}
Run Code Online (Sandbox Code Playgroud)

在上面的CSS中,注意第一个选择器是input[!type].我的意思是我想选择未指定type属性的所有输入框(因为它默认为文本但input[type='text']与之不匹配).不幸的是,我找不到CSS3规范中没有这样的选择器.

有谁知道这样做的方法?

css css-selectors css3

298
推荐指数
3
解决办法
12万
查看次数

标签 统计

css ×1

css-selectors ×1

css3 ×1