问题:
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
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4492926