打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
CSS3 iphone式开关的推荐写法 – W3Cshare前端分享
话说这个问题纠结了近一个小时,为什么呢?看看就知道了。
  在公司的商旅Web移动版本项目上有这么一个交互,需要模仿iphone自带的开关,好吧,肯定没什么问题。
  Tip:请使用Chrome查看以下案例
  点此查看实例展示
  写啊写,代码出来了:
  .onoff{ overflow: hidden; display: inline-block; margin:0 0 -5px 15px; width: 60px;height:20px; border-radius: 20px; border: solid 1px #999;}
       .onoff label{ display: block; margin-left: -40px; width: 100px;height: 20px; text-align: right;color: #8B8B8B;border-radius:20px; background: -webkit-gradient(linear,left top,left bottom,color-stop(0,#DFDFDF),color-stop(1,#FEFEFE));}
         .onoff label::after{ position: relative;left:-17px;top: -20px; display: inline-block; content: '';width: 6px;height: 6px; border: solid 2px #999; border-radius: 10px;}.onoff i{ display: block; width: 60px;height: 20px; border-radius:20px; background: -webkit-gradient(linear,left top,left bottom,color-stop(0,#FE7D00),color-stop(1,#FEA753));}.onoff i::before{ position: relative;top: -7px;left:-15px; display: inline-block; content: '';width: 2px;height: 10px; background-color: #fff;}.onoff i::after{ position: relative;top: -1px;left:1px; display: inline-block; content: '';width: 20px;height: 20px; border: solid 1px #999; border-radius: 50px; background: -webkit-gradient(linear,left top,left bottom,color-stop(0,#DADADA),color-stop(1,#FAFAFA)); box-shadow: inset 0 0 1px #fff;}
  点此查看实例展示
  本文转载自:大前端 ? CSS3 iphone式开关的推荐写法
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
iPhone中必须关闭的3个开关,你关了么?
没有用一张图片,完全用CSS3渲染出iPhone 4
Html Hack,css hack写法
[css] 第83天 IE(6/7/8/9/10/11/Edge)下的hack写法分别有哪些?
前端工程师新手必读
css对话框的写法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服