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%);
      }
    }
  }
 
相关推荐
爱吃羊的老虎1 分钟前
Streamlit:快速创建应用界面,无需了解 Web 开发
前端·python
满栀5853 分钟前
三级联动下拉框
开发语言·前端·jquery
杨超越luckly11 分钟前
HTML应用指南:利用GET请求获取网易云热歌榜
前端·python·html·数据可视化·网易云热榜
前端_yu小白11 分钟前
React实现Vue的watch和computed
前端·vue.js·react.js·watch·computed·hooks
多看书少吃饭14 分钟前
OnlyOffice 编辑器的实现及使用
前端·vue.js·编辑器
编程之路从0到121 分钟前
JSI入门指南
前端·c++·react native
开始学java22 分钟前
别再写“一锅端”的 useEffect!聊聊 React 副作用的逻辑分离
前端
百度地图汽车版27 分钟前
【智图译站】基于异步时空图卷积网络的不规则交通预测
前端·后端
qq_124987075330 分钟前
基于Spring Boot的“味蕾探索”线上零食购物平台的设计与实现(源码+论文+部署+安装)
java·前端·数据库·spring boot·后端·小程序
编程之路从0到132 分钟前
React Native 之Android端 Bolts库
android·前端·react native