当 <input> 或 <a> 为时,如何更改父 <div> 的背景:聚焦(或任何其他动态伪类?
How can I change the background of a parent <div> when an <input> or <a> is :focus'd (or any other dynamic pseudo-class?
例如
<div id="formspace">
<form>
<label for="question">
How do I select #formspace for the case when a child is active?</label>
<input type="text" id="question" name="answer"/></form></div>
很遗憾,css 不支持父选择器.:(
所以唯一的方法就是使用像 jQuery 父方法这样的 javascript.
Unfortunately css doesn't support parent selectors. :(
So the only way to do it is to use javascript like the jQuery parent method.
更新:CSS 选择器 Level 4 将支持父选择器!http://www.w3.org/TR/selectors4/#subject
Update: CSS Selectors Level 4 will support parent selectors! http://www.w3.org/TR/selectors4/#subject
这篇关于影响 :focus'd 元素的父元素(首选纯 CSS+HTML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
:target 为空时的 CSS 选择器CSS selector when :target empty(:target 为空时的 CSS 选择器)
CSS 直接后代 (>) 在选择性方面没有任何价值Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在选择性方面没有任何价值吗?)
使用 querySelectorAll().方法返回的结果是否有序?Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的结果是否有序?)
Safari 错误:当使用 JS 删除项目时,first-child 不更Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 错误:当使用 JS 删除项目时,first-child 不更新
nth-子 CSS 选择器nth-Child CSS selectors(nth-子 CSS 选择器)
对多个 HTML 标签使用相同的 ID?Using same ID for multiple HTML tags?(对多个 HTML 标签使用相同的 ID?)