CSS calc()函数中的Sass变量

本小妞迷上赌 提交于 2020-08-14 06:43:38

问题:

I'm trying to use the calc() function in a Sass stylesheet, but I'm having some issues. 我正在尝试在Sass样式表中使用calc()函数,但是遇到了一些问题。 Here's my code: 这是我的代码:

$body_padding: 50px

body
    padding-top: $body_padding
    height: calc(100% - $body_padding)

If I use the literal 50px instead of my body_padding variable, I get exactly what I want. 如果我使用文字50px而不是我的body_padding变量,那么我得到的正是我想要的。 However, when I switch to the variable, this is the output: 但是,当我切换到变量时,这是输出:

body {
    padding-top: 50px;
    height: calc(100% - $body_padding); }

How can I get Sass to recognize that it needs to replace the variable within the calc function? 如何让Sass认识到它需要替换calc函数中的变量?


解决方案:

参考一: https://stackoom.com/question/1DRy3/CSS-calc-函数中的Sass变量
参考二: https://oldbug.net/q/1DRy3/Sass-Variable-in-CSS-calc-function
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!