• scss


    scss

    SASS是CSS3的一个扩展,增加了规则嵌套、变量、混合、选择器继承等等。

    在SCSS中使用变量

    $blue: #3bbfce;
    
    $margin: 16px;
    
    
    .content-navigation {
    
      border-color: $blue;
    
      color:
    
    darken($blue, 9%);
    
    }
    
    
    .border {
    
      padding: $margin / 2;
    
      margin: $margin / 2;
    
      border-color: $blue;
    
    }
    

    转换成CSS如下:

    /* CSS */
    
    .content-navigation {
    
      border-color: #3bbfce;
    
      color: #2b9eab;
    
    }
    
    
    .border {
    
      padding: 8px;
    
      margin: 8px;
    
      border-color: #3bbfce;
    
    }
    

    SCSS嵌套:

    table.hl {
    
      margin: 2em 0;
    
      td.ln {
    
    text-align: right;
    
      }
    
    }
    
    
    li {
    
      font: {
    
    family: serif;
    
    weight: bold;
    
    size: 1.2em;
    
      }
    
    }
    

    转换成CSS如下:

    /* CSS */
    
    
    table.hl {
    
      margin: 2em 0;
    
    }
    
    table.hl td.ln {
    
      text-align: right;
    
    }
    
    
    li {
    
      font-family: serif;
    
      font-weight: bold;
    
      font-size: 1.2em;
    
    }
    

    使用@mixin命令,定义一个代码块。

      @mixin left {
        float: left;
        margin-left: 10px;
      }
    

    使用@include命令,调用这个mixin。

      div {
        @include left;
      }
    

    循环语句

    SASS支持for循环:

      @for $i from 1 to 10 {
        .border-#{$i} {
          border: #{$i}px solid blue;
        }
      }
    

    也支持while循环:

      $i: 6;
    
      @while $i > 0 {
        .item-#{$i} {  2em * $i; }
        $i: $i - 2;
      }
    

    each命令,作用与for类似:

      @each $member in a, b, c, d {
        .#{$member} {
          background-image: url("/image/#{$member}.jpg");
        }
      }
    

    循环语句

    SASS支持for循环:

      @for $i from 1 to 10 {
        .border-#{$i} {
          border: #{$i}px solid blue;
        }
      }
    

    也支持while循环:

      $i: 6;
    
      @while $i > 0 {
        .item-#{$i} {  2em * $i; }
        $i: $i - 2;
      }
    

    each命令,作用与for类似:

      @each $member in a, b, c, d {
        .#{$member} {
          background-image: url("/image/#{$member}.jpg");
        }
      }
  • 相关阅读:
    POJ 3694 Network (求桥,边双连通分支缩点,lca)
    UVA 796
    UVA 315 315
    POJ 1236 Network of Schools (有向图的强连通分量)
    【转】有向图强连通分量的Tarjan算法
    HDU 3072 Intelligence System (强连通分量)
    【转】强大的vim配置文件,让编程更随意
    WORDPRESS登录后台半天都无法访问或者是访问慢的解决方法
    phpstorm+Xdebug断点调试PHP
    PHP性能调优---PHP调试工具Xdebug安装配置教程
  • 原文地址:https://www.cnblogs.com/tang-lei/p/4660277.html
Copyright © 2020-2023  润新知