html - 字体大小覆盖其他样式

标签 html css removing-whitespace

我正在尝试使用 font-size:0; hack 来消除网格系统上的空白区域。

我已将主体字体大小设置为 0,然后在其他地方指定我的文本的大小。

然而 font-size:0;似乎覆盖了并且看不到我的文本?

JS Fiddle

div{font-size:0;}
h1{font-size:1.5em;}

最佳答案

em 值是相对于父元素上的字体大小定义的。因此,在这种情况下,1.5em; 的计算值将是 0

你可以use a root-em remfixed length value as px .

15.7 Font size: the 'font-size' property

'em' and 'ex' length values refer to the computed font size of the current element. On the 'font-size' property, these length units refer to the computed font size of the parent element.

关于html - 字体大小覆盖其他样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25622076/

相关文章:

html - 如何对齐选项卡旁边的图像

wordpress - 谷歌字体渲染问题?机器人

c# - 字符串连接如何忽略空值和换行符

Python newspace 持续存在

html - 背景重复在 Internet Explorer 中不起作用

html - flex 元素和水平滚动的问题

javascript - 在基于 ajax 的网站的动态加载内容上运行 javascript

css - 为什么位置: sticky; not work in react?

css - 菜单下拉显示在错误的位置

python - 删除python3中html标签之间的换行符