Sass负变量值? [英] Sass negative variable value?

查看:168
本文介绍了Sass负变量值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个scss选择器,我使用相同的正数和负数,如:

  padding:0 15px 15px; 
margin:0 -15px 20px -15px;

我想为所有15px的数量使用一个变量,但这不工作: / p>

  $ pad:15px; 
padding:0 $ pad $ pad;
margin:0 - $ pad 20px - $ pad;

保证金金额转换为正数。

p> margin:0( - $ pad)20px( - $ pad);


I have a couple of scss selectors where I use the same amount positive and negative, as in:

padding: 0 15px 15px;
margin: 0 -15px 20px -15px;

I'd prefer to use a variable for all the 15px amounts, but this does not work:

$pad: 15px;
padding: 0 $pad $pad;
margin: 0 -$pad 20px -$pad;

The margin amounts convert to positive numbers. Am I missing something?

解决方案

Try it like this

margin: 0 (-$pad) 20px (-$pad);

这篇关于Sass负变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆