如何通过SASS中的父母计算字体大小?

Jov*_*ern 5 css styles sass font-size

我的scss文件中有几个标题:

h1{font-size:18px}
h2{font-size:16px}
h3{font-size:12px}
Run Code Online (Sandbox Code Playgroud)

在我的index.html中我得到了这个:

<h1>Heading <span>Secondary text</span></h1>
<h2>Heading <span>Secondary text</span></h2>
<h3>Heading <span>Secondary text</span></h3>
Run Code Online (Sandbox Code Playgroud)

我想计算SPAN标签的字体大小,拉特说..字体大小等于减去2px到包含他的标题?

小智 5

你不需要SASS.只需使用calc.就像是:

.h3 span {
    font-size: calc(100% - 2px);
}
Run Code Online (Sandbox Code Playgroud)