影响的父元素:focus'd元素(纯CSS + HTML首选) [英] Affecting parent element of :focus'd element (pure CSS+HTML preferred)

查看:503
本文介绍了影响的父元素:focus'd元素(纯CSS + HTML首选)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< input> 时,如何更改父级的背景< div> code>< a> 是:focus'd(或任何其他动态伪类?



Eg

 < div id =formspace> 
< form>
< label for =question >
如何为子活动的情况选择#formspace?< / label>
< input type =textid =questionname =answer/> ;< / form>< / div>


解决方案

不幸的是,css不支持父选择器。(

因此,唯一的方法是使用类似于 jQuery parent method



更新:
CSS Selectors Level 4将支持父选择器! http://www.w3.org/TR/selectors4/#subject p>

How can I change the background of a parent <div> when an <input> or <a> is :focus'd (or any other dynamic pseudo-class?

Eg

<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>

解决方案

Unfortunately css doesn't support parent selectors. :(
So the only way to do it is to use javascript like the jQuery parent method.

Update: CSS Selectors Level 4 will support parent selectors! http://www.w3.org/TR/selectors4/#subject

这篇关于影响的父元素:focus'd元素(纯CSS + HTML首选)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆