不是CSS选择器 [英] Not CSS selectors
本文介绍了不是CSS选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否存在某种非" CSS选择器?
Is there some kind of "not" CSS selector?
例如,当我在CSS中编写以下行时,标记内类为 classname 的所有输入字段将具有红色背景.
For example when I write the following line in my CSS, all input fields inside an tag with class classname will have a red background.
.classname input {
background: red;
}
如何选择类 classname 的标签之外的所有输入字段?
How do I select all input fields that are OUTSIDE of a tag with class classname?
推荐答案
无法使用当前的浏览器CSS支持.
With current browser CSS support, you can't.
较新的浏览器现在支持它-有关更多信息,请参见 Sam的答案./em>
(有关CSS的替代方法,请参见其他答案.)
(See other answers for the alternatives in CSS.)
如果可以在JavaScript/jQuery中执行此操作,则可以执行以下操作:
If doing it in JavaScript/jQuery is acceptable, you can do:
$j(':not(.classname)>input').css({background:'red'});
这篇关于不是CSS选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文