当前位置: 首页 > news >正文

Web前端之Sass中的颜色函数、active按钮激活、disabled禁用、hover鼠标悬浮、Style循环、Css

MENU

  • 效果图
  • Html
  • Sass
  • Scss编译后的Css
  • 页面Css

效果图

注意查看蓝色按钮。





Html

<divclass="box"><buttonclass="btn type_1">按钮</button><buttonclass="btn type_2">按钮</button><buttonclass="btn type_3">按钮</button><buttonclass="btn type_4">按钮</button><buttonclass="btn type_5">按钮妞</button><buttonclass="btn type_6">按钮</button><buttonclass="btn type_7">按钮</button><buttonclass="btn type_8">按钮</button><buttonclass="btn type_9">按钮</button></div>

Sass

$btnColors:#409eff,#67c23a,#f56c6c,#909399,#e6a23c,#fb7806,#8b590f,#f54343,#6c6d71;@for$i from 1 throughlength($btnColors){.btn.type_#{$i}{$color:nth($btnColors,$i);background:$color;color:#ffffff;&:hover{background:lighten($color,10%);}&:active{background:darken($color,10%);}&:disabled{background:lighten($color,10%);color:white;}}}

Scss编译后的Css

.btn.type_1{background:#409eff;color:#ffffff;}.btn.type_1:hover{background:#73b8ff;}.btn.type_1:active{background:#0d84ff;}.btn.type_1:disabled{background:#73b8ff;color:white;}.btn.type_2{background:#67c23a;color:#ffffff;}.btn.type_2:hover{background:#85cf60;}.btn.type_2:active{background:#529b2e;}.btn.type_2:disabled{background:#85cf60;color:white;}.btn.type_3{background:#f56c6c;color:#ffffff;}.btn.type_3:hover{background:#f89c9c;}.btn.type_3:active{background:#f23c3c;}.btn.type_3:disabled{background:#f89c9c;color:white;}.btn.type_4{background:#909399;color:#ffffff;}.btn.type_4:hover{background:#abadb1;}.btn.type_4:active{background:#767980;}.btn.type_4:disabled{background:#abadb1;color:white;}.btn.type_5{background:#e6a23c;color:#ffffff;}.btn.type_5:hover{background:#ecb869;}.btn.type_5:active{background:#d48a1b;}.btn.type_5:disabled{background:#ecb869;color:white;}.btn.type_6{background:#fb7806;color:#ffffff;}.btn.type_6:hover{background:#fc9338;}.btn.type_6:active{background:#cb6003;}.btn.type_6:disabled{background:#fc9338;color:white;}.btn.type_7{background:#8b590f;color:#ffffff;}.btn.type_7:hover{background:#b97614;}.btn.type_7:active{background:#5d3c0a;}.btn.type_7:disabled{background:#b97614;color:white;}.btn.type_8{background:#f54343;color:#ffffff;}.btn.type_8:hover{background:#f87373;}.btn.type_8:active{background:#f21313;}.btn.type_8:disabled{background:#f87373;color:white;}.btn.type_9{background:#6c6d71;color:#ffffff;}.btn.type_9:hover{background:#85868b;}.btn.type_9:active{background:#535457;}.btn.type_9:disabled{background:#85868b;color:white;}

页面Css

body{padding:0;box-sizing:border-box;margin:0;min-height:100vh;display:flex;justify-content:center;align-items:center;}.box{width:100%;display:flex;justify-content:center;}button{margin:0;padding:8px 16px;box-sizing:border-box;border:none;outline:none;background-color:transparent;border-radius:2px;cursor:pointer;}button:not(:first-child){margin-left:20px;}
http://www.jsqmd.com/news/446825/

相关文章:

  • 海康威视网络摄像头配置本地存储服务器进行录像和查看!(需要有老版本存储服务器软件和4200老版本搭配使用,官网没有了)
  • VisualStudioCode之各种配置介绍、终端不能运行yarn脚本、自动添加或补全双引号、文件头部的注释说明、保存时禁止格式化、重新加载窗口
  • 【KEIL】【JLINK】KEIL如何进行远程调试
  • 2026年商用咖啡机厂家深度测评:基于全链路能力与创新实效的四维战力解析 - 品牌推荐
  • 2026年商用咖啡机厂家权威榜单发布:五大品牌技术实力与服务网络深度排位赛 - 品牌推荐
  • 蓝桥杯嵌入式(STM32G431RBT6)入门第三天——使用按键(KEY)|CSDN创作打卡
  • ARM-MPU内存保护单元详解
  • 《计算机体系结构基础》课程速看(一)
  • 物联网之Arduino编程语言、条件语句、循环语句、变量、数组、函数
  • Web前端之页面可见性与元素重叠、懒加载、显示、隐藏、交叉、IntersectionObserver、visibilitychange
  • 怎么一步步实现小米智能家居之玄关篇
  • 探索PQ控制三相并网逆变器:从理论到仿真
  • 蓝桥杯嵌入式(STM32G431RBT6)入门第二天——建立自己的初始化文件|CSDN创作打卡
  • 服务端之NestJS中获取完整请求Host的四种封装方式及应用场景、Service与拦截器对比、工具函数、装饰器
  • SAP HANA SQLScript 性能定位的起手式:用支持性工具锁定主导语句与主导算子
  • Cadence
  • 蓝桥杯嵌入式(STM32G431RBT6)入门第一天——点亮LED|CSDN创作打卡
  • Web前端之监听元素的重叠度、设置所有元素的滚动条宽度都为0、节点布局的交叉状态、生成随机图片、阮一峰、标签、IntersectionObserver
  • 【解决】Ping 不是内部或外部命令,也不是可运行的程序或批处理文件
  • Python相关问题
  • 算法---LeetCode 剑指 Offer 26. 树的子结构
  • Web前端之上传文件夹、webkitdirectory
  • 通俗易懂解释知识图谱(Knowledge Graph)
  • Web前端之实现酷炫的仪表进度条、JavaScript动态设置Css属性值、标签元素属性选择器、hsl样式函数
  • 优先队列(priority_queue)总结
  • Web前端之实现累计功能、原生与UniApp版微信小程序两种方式实现、计算、累加、getElementById、innerHTML、Number
  • 在 SAP Kyma 上使用 Redis 服务
  • Web前端之鼠标悬浮,鼠标移入和鼠标移出、getElementById、onmouseover、onmouseout、mouseenter、mouseleave、hover
  • 读懂 Cost-Based Optimization:SAP HANA SQL 优化器如何用成本模型选出更快的执行计划
  • 这才是未来的“openclaw”