博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
css选择器匹配没有属性x的元素[重复]
阅读量:2289 次
发布时间:2019-05-09

本文共 1891 字,大约阅读时间需要 6 分钟。

本文翻译自:

This question already has an answer here: 这个问题在这里已有答案:

  • 9 answers 9个答案

I'm working on a CSS file and find the need to style text input boxes, however, I'm running into problems. 我正在研究CSS文件并发现需要设置文本输入框的样式,但是,我遇到了问题。 I need a simple declaration that matches all these elements: 我需要一个匹配所有这些元素的简单声明:

... but doesn't match these ones: ......但不符合这些:

Here's what I would like to do: 这就是我想做的事情:

input[!type], input[type='text'], input[type='password'] {   /* styles here */}

In the above CSS, notice the first selector is input[!type] . 在上面的CSS中,注意第一个选择器是input[!type] What I mean by this is I want to select all input boxes where the type attribute is not specified (because it defaults to text but input[type='text'] doesn't match it). 我的意思是我想选择未指定type属性的所有输入框(因为它默认为文本但input[type='text']与它不匹配)。 Unfortunately, there is no such selector in the CSS3 spec that I could find. 不幸的是,我找不到CSS3规范中没有这样的选择器。

Does anyone know of a way to accomplish this? 有谁知道这样做的方法?


#1楼

参考:


#2楼

只是想添加到这个,你可以使用selectivizr在oldIE中使用:not selector: ://selectivizr.com/


#3楼

:not selector :不是选择器

input:not([type]), input[type='text'], input[type='password'] {   /* style here */}

in Internet Explorer 9 and higher 在Internet Explorer 9及更高版本中


#4楼

For a more cross-browser solution you could style all inputs the way you want the non-typed, text, and password then another style the overrides that style for radios, checkboxes, etc. 对于更多跨浏览器的解决方案,您可以按照您希望的方式设置所有输入的样式,非文本和密码,然后另一种样式覆盖无线电,复选框等样式。

input { border:solid 1px red; }input[type=radio], input[type=checkbox], input[type=submit], input[type=reset], input[type=file]       { border:none; }

- Or - - 要么 -

could whatever part of your code that is generating the non-typed inputs give them a class like .no-type or simply not output at all? 你生成非类型输入的代码的任何部分都可以为它们提供类似.no-type或者根本不输出它们? Additionally this type of selection could be done with jQuery. 此外,这种类型的选择可以使用jQuery完成。

转载地址:http://bzjnb.baihongyu.com/

你可能感兴趣的文章
SUID和SGID可执行文件
查看>>
恢复已删除文件
查看>>
对敏感备份数据加密
查看>>
升级zlib
查看>>
扫描工具nmap
查看>>
linux Rootkit检查
查看>>
日志集中收集工具Syslog-ng+rsyslog+logrotate
查看>>
缓存的作用和重要指标
查看>>
Docker定制私有镜像
查看>>
Docker资源限制
查看>>
Docker容器跨主机通讯
查看>>
Docker单机编排docker-compose
查看>>
Docker数据管理
查看>>
Dockerfile创建镜像
查看>>
Docker镜像仓库搭建 图形化Harbor
查看>>
Kubernetes集群组件安装(二进制安装)
查看>>
阿里云ECS磁盘在线扩容后扩容磁盘
查看>>
K8S控制器Deployment
查看>>
Ambari安装
查看>>
使用ambari创建Hadoop集群
查看>>