Scss使用

Scss

1.编译scss

在项目所在文件夹中打开集成终端或者cmd

输入:sass -w scss:css

  sass  监听(-w watch)  scss:css --scss文件夹中编译到css文件夹中,注意:其中scss文件夹和css文件夹在同一级,且在统一文件夹下

2.解决中文注释问题

在scss中不能出现中文字符,否则会编译失败,但有可能出现中文注释,因此要在scss文件最顶端加入@charset "utf-8";规则,保证当前文件内可以使用所有能使用utf-8编码规则的文字。

因为scss中注释为//,css中注释为/* */

3.父选择器&

@charset "utf-8";
// 导入文件
// ul >li*3  li颜色不同
ul{
    li{
        width: 50px;
    }
    &>:nth-child(1){background-color: pink;}
    &>:nth-child(2){background-color: plum;}
    &>:nth-child(3){background-color: paleturquoise;}
}
ul{
    li{
        width: 50px;
    }
    &:nth-child(1){background-color: pink;}
    &:nth-child(2){background-color: plum;}
    &:nth-child(3){background-color: paleturquoise;}
}

4.导入其他scss文件夹

@import “写其他scss的文件路径”

@import "1.scss";

3.混合样式mixin

@mixin btn {
    background-color: paleturquoise;
    color: rgb(255, 255, 255);
    font-size: 14px;
    border: 0;
    border-radius: 50%;
}
button{
    @include btn;
    width: 130px;
    height: 40px;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值