“foo that contains bar”的CSS选择器? [英] CSS selector for "foo that contains bar"?
问题描述
可能重复:
是否有CSS父选择器?
有一种方法可以使一个CSS选择器匹配以下?
所有OBJECT元素
里面有一个PARAM元素其中
选择器
OBJECT PARAM
无效,因为它与PARAM匹配,物体。我想将{display:none}应用到对象上;
(我知道我可以使用jQuery - $(object param ).closest(object)
- 但我试图在页面上创建CSS规则。)
否,您要查找的内容将被称为父选择器。 CSS没有;他们已经提出了多次,但我知道没有现有或即将出台的标准,包括他们。你是正确的,你需要使用像jQuery或使用额外的类注释来实现你想要的效果。
这里是一些类似的问题,类似的结果: p>
Possible Duplicate:
Is there a CSS parent selector?
Is there a way to make a CSS Selector that matches the following?
All OBJECT elements
which have a PARAM element inside of them
The selector
OBJECT PARAM
doesn't work, as it matches the PARAM, not the OBJECT. I'd like to apply { display:none } to the objects; it's useless to apply that to the PARAMs.
(I'm aware I could pull this off with jQuery -- $("object param").closest("object")
-- but I'm trying to create CSS rules on a page.)
No, what you are looking for would be called a parent selector. CSS has none; they have been proposed multiple times but I know of no existing or forthcoming standard including them. You are correct that you would need to use something like jQuery or use additional class annotations to achieve the effect you want.
Here are some similar questions with similar results:
- Is there a CSS parent selector?
- CSS Parent/Ancestor Selector
- Complex CSS selector for parent of active child
这篇关于“foo that contains bar”的CSS选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!