SASS循环

html 复制代码
<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>
css 复制代码
@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%);
      }
    }
  }
 
相关推荐
Next_Tech_AI2 分钟前
别用 JS 惯坏了鸿蒙
开发语言·前端·javascript·个人开发·ai编程·harmonyos
-凌凌漆-26 分钟前
【vue】选项式api与组合式api
前端·javascript·vue.js
0思必得02 小时前
[Web自动化] Selenium处理文件上传和下载
前端·爬虫·python·selenium·自动化·web自动化
phltxy3 小时前
Vue3入门指南:从环境搭建到数据响应式,开启高效前端开发之旅
前端·javascript·vue.js
小飞大王6663 小时前
CSS基础知识
前端·css
Charlie_lll3 小时前
学习Three.js–风车星系
前端·three.js
代码游侠3 小时前
学习笔记——Linux内核与嵌入式开发1
linux·运维·前端·arm开发·单片机·嵌入式硬件·学习
腾讯蓝鲸智云3 小时前
【运维自动化-节点管理】节点管理跟配置平台的联动关系
运维·服务器·经验分享·自动化·sass·paas
玩电脑的辣条哥3 小时前
幽灵回复AI已回复但前端不显示的排查与修复
前端·人工智能
石去皿3 小时前
轻量级 Web 应用 —— 把一堆图片按指定频率直接拼成视频,零特效、零依赖、零命令行
前端·音视频