本文介紹了影響 :focus'd 元素的父元素(首選純 CSS+HTML)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
當 <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模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!