css - CSS > 选择器传播到孩子之外?
问题描述
我以为parent > child
只会针对儿童而不是大儿童元素。
body {
font-size: 16px;
}
.child {
border-color: green;
}
.grandchild {
border-color: blue;
}
.great-grandchild {
border-color: purple;
}
/* SHOULDN'T THIS TARGET ONLY THE IMMEDIATE CHILDREN ? */
.parent > div {
font-size: 32px;
background: #DDD;
}
div {
padding: 10px;
border: 1px solid black;
margin: 5px;
}
<div class="parent">
PARENT Font size = 16px as defined by body{}
<div class="child">
CHILD: Font size: 32px (as expected)
<div class="grandchild">
GRANDHCHILD:<br> Shouldn't font-size = 16px?
</div>
<div class="grandchild">
GRANDHCHILD:<br> Shouldn't font-size = 16px?
</div>
<div class="grandchild">
GRANDHCHILD:<br> Shouldn't font-size = 16px?
<div class="great-grandchild">
great grand child<br> Shouldn't font-size = 16px?
</div>
</div>
</div>
</div>
解决方案
推荐阅读
- javascript - 换行文本的 JavaScript 正则表达式
- javascript - JavaScript 仅在运算结果 < 100 时运行运算
- python - 如何在 ID 行后跟值行的文件中按 ID 对行进行分组?
- android - 如何在 Android 中以编程方式(无布局)获取 camera2 预览帧?
- laravel - Auth::check() 在自定义中间件中返回 false,怎么了?
- math - 为什么在执行 PCA 时计算特征向量和特征值如此有效?
- bash - 在 CLion 中导入 ROS 项目和工作区时出错
- arrays - 数组可以在 C 中的单个索引中存储多个值吗?
- flutter - Flutter:StreamProvider 的奇怪行为,使用不完整数据重建的小部件
- reactjs - 处理减量到负值