更改输入上的父 div[type=checkbox]:用 css 检查
- 作者: 那晚越女说我?
- 来源: 51数据库
- 2022-10-20
问题描述
我可以弄清楚如何在选中复选框时更改父 div :(更改以下段落效果很好.
I can figure out how to make the parent div change when checkbox is checked :( Changing the following paragraph works fine.
在 Chrome 中尝试了这种方法,但没有运气:
Tried this approach without luck in Chrome:
HTML
?<div>
<input type="checkbox??????????????????????????????" checked>
<p>Test</p>
</div>???????????????????????????????????????????????
CSS
div {
background: pink;
width: 50px;
height:50px;
}
div + input[type=checkbox]:checked {
background: green;
}
input[type=checkbox]:checked + p {
background: blue;
}
http://jsfiddle.net/lajlev/3xUac/
推荐答案
没有办法只用 CSS 选择父级(直到 CSS4),所以你必须使用 JS..
No way to select a parent with CSS only (until CSS4), so you must use JS..
查看这篇谈论它的帖子这里.
See this post that talking about it here.
推荐阅读
热点文章
检查拆分键盘
0
带有“上一个"的工具栏和“下一个"用于键盘输入AccessoryView
0
Activity 启动时显示软键盘
0
UIWebView 键盘 - 摆脱“上一个/下一个/完成"酒吧
0
在 iOS7 中边缘滑动时,使键盘与 UIView 同步动画
0
我的 iOS 应用程序中的键盘在 iPhone 6 上太高了.如何在 XCode 中调整键盘的分辨率?
0
android:inputType="textEmailAddress";- '@' 键和 '.com' 键?
0
禁用 iPhone 中键盘的方向
0
Android 2.3 模拟器上的印地语键盘问题
0
keyDown 没有被调用
0
