zoukankan      html  css  js  c++  java
  • less 循环

     // colors
    @colors: darkslateblue mediumorchid seagreen steelblue;
    
    // loop definition
    .backgrounds(@list, @i: 1) when (@i <= length(@list)) {
      // extract the right color from the list
      @color: extract(@list, @i);
      // apply the background to the selector
      .@{color} {
        background: @color;
      }
      // recursive call for the next color
      .backgrounds(@list, @i + 1);
    }
    // application
    .backgrounds(@colors);

    示例

    @colors: #3498DB,#3FB17C,#F1C40F,#E74C3C,#1ABC9C,#34495E,#E67E22,#D74177,#6884F6,#2ECC71,#9B59B6,#95A5A6;
    
    .colors(@i: length(@colors)) when (@i > 0) {
      @color: extract(@colors, @i);
      &-@{i} {
        background-color: @color;
      }
      .colors((@i - 1));
    }
  • 相关阅读:
    Java-集合类汇总
    Java-ArrayList
    Java-ArrayList和Vector的区别
    Java-List
    Java-Stack
    Java-Vector
    Java-HashMap
    Java-EnumSet
    18校招借鉴
    spring的设计模式
  • 原文地址:https://www.cnblogs.com/mary-123/p/12246498.html
Copyright © 2011-2022 走看看