scss基础

SCSS 是 Sass 3 引入新的语法,其语法完全兼容 CSS3,并且继承了 Sass 的强大功能。

例如:#sidebar {
  width: 30%;
  background-color: #faa;
}
编译前#sidebar {
  a { text-decoration: none; }
}
编译后#sidebar { a { text-decoration: none } }

变量法:

$bg:#d5d5d5;
使用
div{
  color: $bg;
}
  编译后
  div{color:#d5d5d5}

MIXINS 方法

定义方法  方法名  参数@mixin rounded($amount) {
  -moz-border-radius: $amount;
  -webkit-border-radius: $amount;
  border-radius: $amount;
}
使用 include .box {
  border: 3px solid #777;
  @include rounded(0.5em);
}

scss中不支持calc不同单位计算

.app-inner {
    display: flex;
    height: calc(100% - $topbar-height);
}

如图


扫描二维码关注公众号,回复: 1611177 查看本文章

可以看到sass并没有解析这个$topbar-height。

最后在github的issue中找到了方法,要想在sass的calc中使用变量,必须对这个变量使用sass的插值方法(#{$variable})。

正确写法:

.app-inner {
    display: flex;
    height: calc(100% - #{$topbar-height});
}
issue地址:  点击打开链接

猜你喜欢

转载自blog.csdn.net/qq_37818095/article/details/80367665