当前位置: 首页 > 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.dtcms.com/a/267965.html

相关文章:

  • 深入理解 classnames:React 动态类名管理的最佳实践
  • 20250706-6-Docker 快速入门(上)-镜像是什么?_笔记
  • TNNLS期刊接受后,最终版提交说明
  • QT - QCustomPlot
  • Next.js面试常问内容详解
  • 【网络安全基础】第八章---电子邮件安全
  • 5种高效解决Maven依赖冲突的方法
  • 基于SpringBoot和Leaflet集成在线天气服务的区县当前天气WebGIS实战
  • 手机电工仿真软件更新了
  • Typecho主题开发指南:现代框架布局与SEO优化实践
  • 基于SSM和JSP开发的旅游系统
  • [论文阅读] 人工智能 + 软件工程 | 自然语言驱动结构代码搜索:突破DSL学习壁垒的创新方法
  • HRDNet: High-resolution Detection Network for Small Objects论文阅读
  • 7.6 hash | rust
  • 408第三季part2 - 计算机网络 - 传输层II
  • 前端开发问题:TypeError: records is not iterable
  • Gin Web 层集成 Viper 配置文件和 Zap 日志文件指南(下)
  • Spring Cloud Alibaba/Spring Boot整合华为云存储实例(REST API方式)
  • 记一次JVM问题排查
  • 字节二面:进程,线程,协程区别
  • K8s系列之:Kubernetes 的 OLM
  • 一些共识协议与算法
  • docker 无法拉取镜像解决方法
  • 【机器学习深度学习】混淆矩阵解读
  • 算法分析与设计实验1:实现两路合并排序和折半插入排序
  • PLC 智能设备 (I-Device):从原理到实战的 Profinet 通信进阶
  • SwiftUI 7(iOS 26 / iPadOS 26)中玻璃化标签页的全新玩法
  • Vue3路由跳转优化:让你的页面切换像德芙一样丝滑 [特殊字符]
  • 【认知】如何强化优先做紧急重要的事,而不是按兴趣做重要但不紧急的事
  • 黑马点评系列问题之实战篇02短信登录 利用资料中的mysql语句创建数据表时报错