less 中function

/**
   * .margin(@space, @limit-groups)
   */
  .margin(@space, @index: 10) when (@index > 0 ) {
    @value: @space * @index;
    @valuepx: @value * 1px;

    .ml-@{value} {
      margin-left: @valuepx;
    }

    .mr-@{value} {
      margin-right: @valuepx;
    }

    .mt-@{value} {
      margin-top: @valuepx;
    }

    .mb-@{value} {
      margin-bottom: @valuepx;
    }

    @next: @index - 1;

    .margin(@space, @next);
  }

  .margin(5);

相关推荐