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

纯css实现switch开关

代码比较简单,有需要直接在下边粘贴使用吧~

html:

	<div class="switch-box"><input id="switch" type="checkbox"><label></label></div>

 css:

		.switch-box {position: relative;height: 25px;}.switch-box label {width: 50px;height: 25px;background: #ccc;position: relative;display: inline-block;border-radius: 46px;-webkit-transition: 0.4s;transition: 0.4s;}.switch-box label:after {content: '';position: absolute;width: 21px;height: 25px;border-radius: 100%;left: 0;top: -5px;z-index: 2;background: #fff;box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);-webkit-transition: 0.4s;transition: 0.4s;}.switch-box input {position: absolute;width: 100%;height: 100%;z-index: 5;opacity: 0;}.switch-box label:after {top: 0;width: 23px;height: 23px;margin: 1px 0;}.switch-box input:checked+label {background: #eb8597;}.switch-box input:checked+label:after {left: 30px;}

js:

  $('#switch').change(function (e) {var isChecked = $(this).prop("checked") ? true : false;if (isChecked) {console.log('选中...')} else {console.log('取消选中...')}});

 

 

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

相关文章:

  • Unity3d 微信小游戏 AB资源问题
  • Leetcode二叉树刷题
  • 如何给自己的网站添加 https ssl 证书
  • Vue路由跳转及路由传参
  • 计算机网络常见面试总结
  • 时隔一年,再次讨论下AutoGPT-安装篇
  • 项目三:学会如何使用python爬虫请求库(小白入门级)
  • 【热门话题】PyTorch:深度学习领域的强大工具
  • SQL注入sqli_libs靶场第一题
  • QT_day3
  • 使用ADO.NET访问数据库
  • SpringBoot的旅游管理系统+论文+ppt+免费远程调试
  • 数据结构---线性表
  • MySQL 8.0 字符集问题导致报错
  • 单路高清HDMI编码器JR-3211HD
  • 分库,分表,分区,分片
  • 【详解算法流程+程序】DBSCAN基于密度的聚类算法+源码-用K-means和DBSCAN算法对银行数据进行聚类并完成用户画像数据分析课设源码资料包
  • java es相关操作
  • 腾讯EdgeOne产品测评体验——开启安全防护,保障数据无忧
  • 机器视觉图形处理软件介绍
  • C# WinForm简介
  • 概念:CPU、内存、磁盘、Android内存分配
  • Vue 图片加载失败显示默认图片
  • 【Sentinel的限流使用】⭐️SpringBoot整合Sentinel实现Api的限流
  • 【示例】MySQL-SQL语句优化
  • QT 线程的使用
  • Python基于flask的豆瓣电影分析可视化系统
  • 【迅为iTOP-4412-linux 系统制作(4)】ADB 或者 TF 卡烧写测试
  • 阿里云对象存储OSS批量上传,单个上传,批量删除,单个删除!
  • Python的国际化和本地化【第162篇—国际化和本地化】