scss 语法

scss 是 css 的超集, 主要是引入了 变量, 函数, 继承, 算术计算。

  1. 选着器嵌套
nav {
	ul {
	margin:0;
	}
}
  1. $ 定义变量与使用
$font-stack: Helvetica, sans-serif;
$primary-color:#333

body {
font: 100% $font-stack;
color: $primary-colorl
}
  1. @mixin 定义函数, @include 调用
# theme: 函数名
# arg: 函数参数
# DarkGray: 默认值
@mixin theme($arg: DarkGray){
backgroundz:$arg;
}
# 调用
.info {
@include theme;
}
.alert {
@include theme($arg:DarkRed);
}
  1. % 基类 -> @extend 扩展
# 定义 %equal-heights 基类
%equal-heights{
display:flex;
}
# 使用
.message{
@extend %equal-heights;
background:#333;
}
  1. @use "sass:math"; -> + - * math.dev() %
@use "sass:math";
.container{
display:flex;
}
article[role="main"] {
width:math.div(600px,960px)*100%;
}

  1. 引用 @import 引入其他文件以_开头的文件
# 引入 _base.scss 文件, _base.scss本身不能生成css文件
@import 'base' 
.inverse {
background-color: base.$primary-color;
}

参考:

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值