CSS selector for quot;foo that contains barquot;?(“包含 bar 的 foo的 CSS 选择器?)
问题描述
有没有办法制作符合以下内容的 CSS 选择器?
Is there a way to make a CSS Selector that matches the following?
All OBJECT elements
which have a PARAM element inside of them
选择器
OBJECT PARAM
不起作用,因为它匹配 PARAM,而不是 OBJECT.我想将 { display:none } 应用于对象;将其应用于 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.
(我知道我可以使用 jQuery - $("object param").closest("object") - 和 VanillaJS - document.querySelector("objectparam").closest("object") - 但我正在尝试在页面上创建 CSS 规则.)
(I'm aware I could pull this off with jQuery - $("object param").closest("object") - and VanillaJS - document.querySelector("object param").closest("object") - but I'm trying to create CSS rules on a page.)
推荐答案
不,您要查找的将称为 父选择器.CSS 没有;它们已被多次提出,但我不知道包括它们在内的现有或即将推出的标准.您是正确的,您需要使用 jQuery 之类的东西或使用额外的类注释来实现您想要的效果.
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:
- 是否有 CSS 父选择器?
- CSS 父/祖先选择器
- 活动子的父级的复杂 CSS 选择器
这篇关于“包含 bar 的 foo"的 CSS 选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“包含 bar 的 foo"的 CSS 选择器?
基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
