ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

scss的混入和继承,以及for,each循环

2021-01-24 14:29:21  阅读:334  来源: 互联网

标签:scss flex 混入 color blue father direction each red


index.scss

$color-red:red;
$color-blue:blue;
@mixin flex($direction,$jus-con:'',$ali-itm:'') {
    display: flex;
    @if $direction=='column' {
        flex-direction: column;
    }@else {
        flex-direction: 'xxx';
    }
    justify-content: $jus-con;
    align-items: $ali-itm;
}
.ext{
    color: green;
}
h1.ext {
    font-size: 22px;
}
.father {
    color: $color-red;
    .sonOne {
        @import "./imp.scss";

        background-color: $color-blue;
        .one1 {
            color: $color-blue;
            @extend .ext; 
        }
    }
    .sonTwo {
        // @include flex('row','flex-end','center');
        @include flex($direction:'',$jus-con:center,$ali-itm:center);
        background-color: $color-blue;
        @extend .ext;
    }
    
}
// 插值语句
$border:border;
.#{$border} {
    #{border}:1px solid yellow;
}
// for
@for $i from 1 through 3 {
    .item#{$i} {
        width: 1px*#{$i};
    }
}
// each
@each $item in a,b,c,d,e {
    .test#{$item} {
        color: red;
    }
}
@each $item,$color in (color,red),('width','2px'),('height','3px') {
    .cc {
        #{$item}:#{$color};
    }
}

imp.scss

$color-blue:yellow;

最后编译css为

.ext, .father .sonOne .one1, .father .sonTwo {
  color: green;
}

h1.ext, .father .sonOne h1.one1, .father h1.sonTwo {
  font-size: 22px;
}

.father {
  color: red;
}

.father .sonOne {
  background-color: yellow;
}

.father .sonOne .one1 {
  color: yellow;
}

.father .sonTwo {
  display: flex;
  flex-direction: 'xxx';
  justify-content: center;
  align-items: center;
  background-color: blue;
}

.border {
  border: 1px solid yellow;
}

.item1 {
  width: 1px*1;
}

.item2 {
  width: 1px*2;
}

.item3 {
  width: 1px*3;
}

.testa {
  color: red;
}

.testb {
  color: red;
}

.testc {
  color: red;
}

.testd {
  color: red;
}

.teste {
  color: red;
}

.cc {
  color: red;
}

.cc {
  width: 2px;
}

.cc {
  height: 3px;
}
/*# sourceMappingURL=index.min.css.map */

标签:scss,flex,混入,color,blue,father,direction,each,red
来源: https://blog.csdn.net/Angely_cc/article/details/113087764

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有