• vue+webpack+sass


    一、引入依赖

    npm i node-sass sass-loader -D

    二、配置webpack的loader

    {
        test: /\.sass$/,
        loaders: ['style', 'css', 'sass']
    }

    三、使用

    <style lang="scss">
    @import '*.scss';
    </style>

    四、知识点

     1、变量

    $fontSize: 20px;
    $sideBarWidth: 210px;
    div { font
    -size: $fontSize;
    calc(100% - #{$sideBarWidth}); }

    2、嵌套

    .out {
        color: red;
        .center {
            color: green;
            .in {
                color: blue;
            }
        }
    }

    3、mixin

    @mixin font($family,$size,$weight) {
        font-family: $family;
        font-size: $size;
        font-weight: $weight;
    }
    
    .out {
        @include font('微软雅黑', 30px, bold);
    }
    
    @mixin transition($prop,$time) {
        -webkit-transition: $prop $time;
        -moz-transition: $prop $time;
        -ms-transition: $prop $time;
        -o-transition: $prop $time;
        transition: $prop $time;
    }
    
    .in {
         100px;
        height: 100px;
        background: red;
        @include transition(width, 2s);
    }
    
    .in:hover {
         300px;
    }

    4、扩展

    .out {
         100px;
        height: 30px;
        background: deepskyblue;
        color: #000;
        border-radius: 5px;
    }
    
    .in {
        @extend .out;
        background: yellow;
        color: deeppink;
    }

    5、函数

    $count: 10;
    $designWidth: 640px;
    
    @function px2rem($px) {
        @return $px * $count / $designWidth * 1rem;
    }
    
    .out {
         px2rem(100px);
        height: px2rem(100px);
        background-color: red;
    }

    6、表达式

    @for $i from 1 through 6 {
        .out > .in:nth-of-type(#{$i}) {
            height: 5px;
            background-color: green;
            border-bottom: 1px solid red;
        }
    }
    
    $someEvent: false;
    
    @if $someEvent {
        .center {
             50px;
            height: 50px;
            background-color: yellow;
        }
    } @else {
        .center {
             50px;
            height: 50px;
            background-color: blue;
        }
    }
  • 相关阅读:
    sql server 查看锁表SQL【转】
    在cxGrid表格中如何获得当前列的字段名
    获取cxgrid footer内容
    gulp学习总结
    前端入门应该掌握的html+css知识点
    前端知识回顾
    this、apply/call、bind、闭包、函数、变量复制
    三角形的实现方法(马)
    webpack学习总结(一)
    使用模板引擎artTemplate的几个问题总结
  • 原文地址:https://www.cnblogs.com/linding/p/12401107.html
Copyright © 2020-2023  润新知