scss预处理器(变量,嵌套,混入)

注:scss文件代码必须对其进行编译为css代码文件

$red:#db221d;
// 变量
.box{
    width: 100px;
    height: 100px;
    background-color: aqua;
    // 嵌套
    span{
        color: aqua;
        background-color: red;
    }
}
h2{
    color: $red;
}
button{
    background-color: $red;
}
// 混入
@mixin  btn ($a,$b,$c,$d,$e,$f){
    width: $a;
    height: $b;
    background-color: $c;
    color: $d;
    font-size: $e;
    border-radius: $f;
    border: none;
}
.btn-info{
    @include btn(120px,36px,#0d6efd,#fff,18px,3px)
}
.btn-1{
    @include btn(100px,32px,#198754,#fff,16px,2px)
}

注:html代码文件中引入的css代码是scss编译后的代码

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>变量</title>
        <link rel="stylesheet" href="./2.css">
    </head>
    <body>
        <div class="box">
            <span>123</span>
        </div>
        <h2>标题二</h2>
        <button>按钮</button>
        
        <button class="btn-info">提交</button>
        <button class="btn-1">登录</button>
    </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值