// 父元素状态改变时,改变子元素的css,可以这样写form input{
color: black;}form.active input{
color: red;}那么,子元素状态改变时,怎么改变父元素的css呢?比如:input获取到focus时,怎么改变整个form的颜色?纯css的写法求教大家,谢谢!
2 回答
慕无忌1623718
TA贡献1744条经验 获得超4个赞
<div class="parent">
<form>
<input type="text">
</form></div><style>
.parent:hover input{ background:green;
} .parent:hover form{ background:orange;
}</style>- 2 回答
- 0 关注
- 4545 浏览
添加回答
举报
0/150
提交
取消
