zoukankan      html  css  js  c++  java
  • sass补充(2019-3-9)

    @each 输出

    格式:

    @each $var in value,value1,value2{

    }

    eg:

    @each $var1 in 100px,200px,300px{
      .box{
      width:$var1;
    }
    }
    
    //结果
    
    .box{
    width:100px;
    }
    .box{
    200px;
    }
    .box{
    300px;
    }

    当然,@each的变量还可以写多个,不过要和后面的内容向对应。

    @each $a,$b,$c in ((ab,es,cdd),(cd,da,add)){
      .a{
        background: $a;
        color:$b;
        width: $c;
      }
    }
    
    //结果
    
    .a {
      background: ab;
      color: es;
      width: cdd;
    }
    
    .a {
      background: cd;
      color: da;
      width: add;
    }

    @while 循环输出内容

    格式:

    @while $a>0{}

    eg:

    $i:5;
    @while $i > 0{
      .box{
        background: $i;
      }
      $i:$i - 1;
    } 
    
    //结果
    
    .box {
      background: 5;
    }
    
    .box {
      background: 4;
    }
    
    .box {
      background: 3;
    }
    
    .box {
      background: 2;
    }
    
    .box {
      background: 1;
    }

    混合开发@mixin

    eg:

    // @mixin 混合引用
    $num1:10;
    @mixin txt{
      font:{
        size:$num1+px;
        weight:$num1*10; 
      };
      color:#fff;
      &:hover{
        display: none;
      }
    }
    
    
    // 直接使用不能在里面加父选择器
    .pd{
      @include txt();
      width: 100%;
    }
    
    @mixin txt2{
      .box{
        font:{
          size:10px;
      }
      z-index: $num1*100;
      }
    }
    
    @include txt2();
    
    // 混合模式的参数设定
    
    @mixin txt3($var1,$var2){
      .#{$var1}{
        background: $var2;
      }
    }
    
    @include txt3(box,url("img/1.png"));
    
    // 混合模式参数的默认值
    
    @mixin txt4($var1:div,$var2:#fff){
    .#{$var1}{
      color: $var2;
    }
    }
    
    @include txt4(xxx,#121212);

    混合开发案例结果

    .pd {
      font-size: 10px;
      font-weight: 100;
      color: #fff;
      width: 100%;
    }
    .pd:hover {
      display: none;
    }
    
    .box {
      font-size: 10px;
      z-index: 1000;
    }
    
    .box {
      background: url("img/1.png");
    }
    
    .xxx {
      color: #121212;
    }
  • 相关阅读:
    [HAOI2007][SDOI2005]反素数
    [UVa1636]Headshot
    [Codeforces 581D]Three Logos
    [NOIP2014普及组]子矩阵
    洛谷 P3299 [SDOI2013]保护出题人 解题报告
    洛谷 P3965 [TJOI2013]循环格 解题报告
    洛谷 P3989 [SHOI2013]阶乘字符串 解题报告
    [SHOI2013]发牌 解题报告
    洛谷 P3962 [TJOI2013]数字根 解题报告
    LOJ 2664. 「NOI2013」向量内积 解题报告
  • 原文地址:https://www.cnblogs.com/xiaojianwei/p/10501739.html
Copyright © 2011-2022 走看看