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

【CSS样式】有趣的滑块开关

在这里插入图片描述

样式源码地址

HTML部分代码

<div class="toggle-container"><input class="toggle-input" id="toggle" type="checkbox" /><label class="toggle-label" for="toggle"><div class="face"><div class="eye left-eye"></div><div class="toggle-switch"></div><div class="eye right-eye"></div><div class="smile"></div></div></label>
</div>

CSS部分代码


.toggle-container {position: relative;width: 160px;height: 80px;
}.toggle-input {display: none;
}.toggle-label {position: relative;display: flex;justify-content: center;align-items: center;width: 140px;height: 60px;background: #ff4c4c;border-radius: 30px;box-shadow: 0 5px #b93737;transition: background 0.3s ease-in-out;cursor: pointer;padding: 0 10px;
}.face {position: relative;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;transition: all 0.3s ease-in-out;
}.eye {position: relative;width: 10px;height: 10px;background: white;border-radius: 50%;transition: all 0.3s ease-in-out;
}.smile {position: absolute;bottom: 30px;left: 50%;width: 40px;height: 20px;border: 2px solid transparent;border-radius: 50%;transform: translateX(-50%);transition: all 0.3s ease-in-out;
}.toggle-switch {position: relative;width: 35px;height: 20px;background: white;border-radius: 10px;box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);margin: 0 10px;z-index: 1;
}.toggle-switch:before {content: "";position: absolute;width: 15px;height: 15px;background: #ff4c4c;border-radius: 50%;transition: all 0.3s ease-in-out;top: 50%;left: 3px;transform: translateY(-50%);
}.toggle-input:checked + .toggle-label .toggle-switch:before {background: #28a745;left: 16px;
}.toggle-input:checked + .toggle-label .smile {border-bottom-color: #fff;border-top: none;bottom: 10px;
}.toggle-input:not(:checked) + .toggle-label .smile {border-top-color: #fff;border-bottom: none;bottom: 0;
}.toggle-input:checked + .toggle-label {background: #ced10a;box-shadow: 0 5px #74c027;
}.toggle-input:not(:checked) + .toggle-label {background: #252422;box-shadow: 0 5px #484d48;bottom: 5px;
}.toggle-label:hover .eye {width: 20px;height: 20px;
}@keyframes blink {0%,90%,100% {height: 10px;}95% {height: 2px;}
}.left-eye {animation: blink 3s infinite;
}.right-eye {animation: blink 3s infinite;
}

获取更多样式源码(https://lizitools.com/web/web_style)

在这里插入图片描述

http://www.lryc.cn/news/581431.html

相关文章:

  • Gin Web 服务集成 Consul:从服务注册到服务发现实践指南(下)
  • 【influxdb3】如何使用 SQL 对时间序列数据进行聚合查询
  • CppCon 2018 学习:Woes of Scope Guards and Unique_Resource
  • Redis存储Cookie实现爬虫保持登录 requests | selenium
  • RK3588 源码编译 opencv
  • Java 大视界 -- Java 大数据在智能教育在线课程学习效果影响因素分析与优化设计(334)
  • Web后端开发-SpringBootWeb入门、Http协议、Tomcat
  • Spring Boot + 本地部署大模型实现:优化与性能提升!
  • Docker相关内容
  • 闲庭信步使用图像验证平台加速FPGA的开发:开篇语——跨越软件和硬件开发的鸿沟
  • string类(详解)
  • Linux关机指令详解:shutdown命令的使用指南
  • SpringAI与智能体入门
  • 成为git砖家(12): 看懂git合并分支时冲突提示符
  • Linux操作系统之文件(四):文件系统(上)
  • PADS交互式布局
  • PageRank:互联网的马尔可夫链平衡态
  • 线程锁和线程同步
  • Servlet学习
  • Spring--循环依赖以及三级缓存详解
  • Chat Model API
  • Altium Designer使用教程 第一章(Altium Designer工程与窗口)
  • Eureka和Nacos都可以作为注册中心,它们之间的区别
  • Java类变量(静态变量)
  • 【论文】微服务架构下分布式事务一致性解决方案设计与实践
  • 《数据维度的视觉重构:打造交互式高维数据可视化的黄金法则》
  • Java教程——深入学习guava之并发编程
  • 如何使用backtrace定位Linux程序的崩溃位置
  • Python练习Day1
  • 【C语言刷题】第十一天:加量加餐继续,代码题训练,融会贯通IO模式