Variable Sass dans la fonction CSS calc ()

J’essaie d’utiliser la fonction calc() dans une feuille de style Sass, mais j’ai quelques problèmes. Voici mon code:

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

Si j’utilise le littéral 50px au lieu de ma variable body_padding , j’obtiens exactement ce que je veux. Cependant, quand je passe à la variable, c’est la sortie:

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

Comment puis-je demander à Sass de reconnaître qu’il doit remplacer la variable dans la fonction calc ?

Interpoler:

 body height: calc(100% - #{$body_padding}) 

Pour ce cas, border-box suffirait également:

 body box-sizing: border-box height: 100% padding-top: $body_padding 

Essaye ça:

 @mixin heightBox($body_padding){ height: calc(100% - $body_padding); } body{ @include heightBox(100% - 25%); box-sizing: border-box padding:10px; }