html - 子节点是否从 :root 继承字体大小?
问题描述
如果我将font-size
for 所有内容重置为零,以消除所有意外的空白,然后使用:root
伪类将 font-size 设置为12pt
,则子元素的html
font-size 仍然为零并且需要具有它们的 font-size 属性直接指定。为什么?子节点不继承root的字体大小吗?
* {
font-size: 0;
}
:root {
font-size: 12pt;
font-family: sans-serif;
color: silver;
}
<h1>My Heading</h1>
* {
font-size: 0;
}
:root {
font-size: 12pt;
font-family: sans-serif;
color: silver;
}
h1 {
font-size: 1.8rem;
}
<h1>My Heading</h1>
解决方案
推荐阅读
- php - .htaccess 制作友好网址的问题
- c# - 更新类外的值并在 C# 中保持活动状态?
- java - PSQLException“在表上插入或更新违反外键约束”,“表中不存在键”
- github-actions - 如何为操作/结帐设置正确的路径?
- python - 3D 主机游戏距离检测无法正常工作
- python - 如何将numpy数组转换为形式((value0,row0,column0),(value1,row0,column1)...)?
- excel - 如果在单元格中找到字符串,则删除其下方的所有数据,否则如果未找到字符串,则不执行任何操作
- scala - 有没有办法将默认案例值作为参数传递
- docker-compose - Docker-compose up 不执行更新的 Dockerfile
- r - 我可以得到以下嵌套函数的整洁解决方案吗