SCSS语法中的加减乘除

/*加法*/
$sidebar-width: 220px;
$content-width: 720px;
$gap-width: 1in;

.container {
    width: $sidebar-width+$content-width+$gap-width;
    margin: 0 auto;
}
/*减法*/
$container: 960px;
$sidebar-width: 220px;
$gap-width: 20px;

.content{
    width: $container + $sidebar-width - $gap-width;
    float: left;
}
/*乘法*/
.box {
  width: 10px * 2;
}

$list: twitter,facebook,github,weibo;

@for $i from 1 through length($list){
  .icon-#{nth($list,$i)}{
    background-postion: 0 -2 * $i;
  }
}

/*除法-需要给运算的外面添加一个小括号( )*/
.box {
  width: 100px/2 + 2in;  
}
.box {
  width: (100px/2);  
}
.box {
  width: 100px/2;  
}

/*变量计算*/
$content-width: 720px;
$sidebar-width: 220px;
$gutter: 20px;

.container {
  width: $content-width + $sidebar-width + $gutter;
  margin: 0 auto;
}

Koala编译之后的结果如下:

/*加法*/
.container {
  width: 1036px;
  margin: 0 auto;
}

/*减法*/
.content {
  width: 1160px;
  float: left;
}

/*乘法*/
.box {
  width: 20px;
}

.icon-twitter {
  background-postion: 0 -2;
}

.icon-facebook {
  background-postion: 0 -4;
}

.icon-github {
  background-postion: 0 -6;
}

.icon-weibo {
  background-postion: 0 -8;
}

/*除法-需要给运算的外面添加一个小括号( )*/
.box {
  width: 242px;
}

.box {
  width: 50px;
}

.box {
  width: 100px/2;
}

/*变量计算*/
.container {
  width: 960px;
  margin: 0 auto;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值