SASS循环

<template>
  <div>
    <button class="btn type-1">默认按钮</button>
    <button class="type-2">主要按钮</button>
    <button class="type-3">成功按钮</button>
    <button class="type-4">信息按钮</button>
    <button class="type-5">警告按钮</button>
    <button class="type-6">危险按钮</button>
  </div>
</template>
<script>
export default {
     }
</script>
<style lang="scss" scoped>
@import "./sass_style.scss";

// $btnColors: #000000, #f4b9d1, #7b5194, #262d3b, #1b4fc0, #ffdab9;
// @mixin type-divs($startcolor) {
     
//   @for $i from 1 through length($startcolor) {
     
//     .type-#{
     $i} {
     
//       $color: nth($startcolor, $i);
//       background: $color;
//       color: #fff;
//       width: 350px;
//       height: 85px;
//       &:hover {
     
//         background: lighten($color, 10%);
//       }
//       &:active {
     
//         background: darken($color, 10%);
//       }
//       &:disabled {
     
//         background: lighten($color, 20%);
//         color: lighten($color, 40%);
//       }
//     }
//   }
// }

// @include type-divs($btnColors);
</style>
@charset "utf-8";
$btnColors: #000000, #f4b9d1, #7b5194, #262d3b, #1b4fc0, #ffdab9;
 
@for $i from 1 through length($btnColors) {
   
    .type-#{
   $i}{
   
      $color: nth($btnColors, $i);
      background: $color;
      color: #fff;
      width: 350px;
      height: 85px;
      &:hover {
   
        background: lighten($color, 10%);
      }
      &:active {
   
        background: darken($color, 10%);
      }
      &:disabled {
   
        background: lighten($color, 20%);
        color: lighten($color, 40%);
      }
    }
  }
 

在这里插入图片描述

相关推荐

  1. SASS控制指令与循环

    2023-12-29 07:52:03       8 阅读
  2. scss for循环,$变量,全局样式

    2023-12-29 07:52:03       23 阅读
  3. less和scss循环生成margin和padding

    2023-12-29 07:52:03       10 阅读
  4. Frontend - SASS / SCSS 文件使用

    2023-12-29 07:52:03       37 阅读
  5. CSS预处理器---Sass/Scss

    2023-12-29 07:52:03       44 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-29 07:52:03       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-29 07:52:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-29 07:52:03       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-29 07:52:03       20 阅读

热门阅读

  1. 【Delphi 基础知识 4】类是如何被实例化的?

    2023-12-29 07:52:03       44 阅读
  2. win10 vs c++ 安装vcpkg 类似于pip

    2023-12-29 07:52:03       43 阅读
  3. 案例系列:IBM反洗钱交易数据_GNN节点分类检测

    2023-12-29 07:52:03       31 阅读
  4. 数据库是否可以直接作为数据仓库的数据源

    2023-12-29 07:52:03       39 阅读
  5. Dockerfile: WORKDIR vs VOLUME

    2023-12-29 07:52:03       33 阅读
  6. 今天,你学废了么

    2023-12-29 07:52:03       36 阅读
  7. C++/Qt版餐厅点餐系统模块代码详解

    2023-12-29 07:52:03       36 阅读
  8. 介绍 TensorFlow 的基本概念和使用场景。

    2023-12-29 07:52:03       28 阅读
  9. 【qt】保存debug到log里

    2023-12-29 07:52:03       38 阅读