0

0

一款仿ios7的switches开关按钮_html/css_WEB-ITnose

php中文网

php中文网

发布时间:2016-06-24 11:55:51

|

1607人浏览过

|

来源于php中文网

原创

今天给大家介绍一款仿ios7的switches开关按钮。这款按钮也是纯css实现的。无需引js代码。在实现中给出了两种颜色,三种不同大小的demo。一起看下效果图:

在线预览   源码下载

实现的代码。

html代码:

Picsart(video-editor)
Picsart(video-editor)

Picsart旗下的视频编辑器。

下载

立即学习前端免费学习笔记(深入)”;

   

iOS 7 style switches with CSS

By Bandar Raffah

css代码:

  input[type="checkbox"]        {            position: absolute;            opacity: 0;        }                /* Normal Track */        input[type="checkbox"].ios-switch + div        {            vertical-align: middle;            width: 40px;            height: 20px;            border: 1px solid rgba(0,0,0,.4);            border-radius: 999px;            background-color: rgba(0, 0, 0, 0.1);            -webkit-transition-duration: .4s;            -webkit-transition-property: background-color, box-shadow;            box-shadow: inset 0 0 0 0px rgba(0,0,0,0.4);            margin: 15px 1.2em 15px 2.5em;        }                /* Checked Track (Blue) */        input[type="checkbox"].ios-switch:checked + div        {            width: 40px;            background-position: 0 0;            background-color: #3b89ec;            border: 1px solid #0e62cd;            box-shadow: inset 0 0 0 10px rgba(59,137,259,1);        }                /* Tiny Track */        input[type="checkbox"].tinyswitch.ios-switch + div        {            width: 34px;            height: 18px;        }                /* Big Track */        input[type="checkbox"].bigswitch.ios-switch + div        {            width: 50px;            height: 25px;        }                /* Green Track */        input[type="checkbox"].green.ios-switch:checked + div        {            background-color: #00e359;            border: 1px solid rgba(0, 162, 63,1);            box-shadow: inset 0 0 0 10px rgba(0,227,89,1);        }                /* Normal Knob */        input[type="checkbox"].ios-switch + div > div        {            float: left;            width: 18px;            height: 18px;            border-radius: inherit;            background: #ffffff;            -webkit-transition-timing-function: cubic-bezier(.54,1.85,.5,1);            -webkit-transition-duration: 0.4s;            -webkit-transition-property: transform, background-color, box-shadow;            -moz-transition-timing-function: cubic-bezier(.54,1.85,.5,1);            -moz-transition-duration: 0.4s;            -moz-transition-property: transform, background-color;            box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0px 0px 0 1px rgba(0, 0, 0, 0.4);            pointer-events: none;            margin-top: 1px;            margin-left: 1px;        }                /* Checked Knob (Blue Style) */        input[type="checkbox"].ios-switch:checked + div > div        {            -webkit-transform: translate3d(20px, 0, 0);            -moz-transform: translate3d(20px, 0, 0);            background-color: #ffffff;            box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0px 0px 0 1px rgba(8, 80, 172,1);        }                /* Tiny Knob */        input[type="checkbox"].tinyswitch.ios-switch + div > div        {            width: 16px;            height: 16px;            margin-top: 1px;        }                /* Checked Tiny Knob (Blue Style) */        input[type="checkbox"].tinyswitch.ios-switch:checked + div > div        {            -webkit-transform: translate3d(16px, 0, 0);            -moz-transform: translate3d(16px, 0, 0);            box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0px 0px 0 1px rgba(8, 80, 172,1);        }                /* Big Knob */        input[type="checkbox"].bigswitch.ios-switch + div > div        {            width: 23px;            height: 23px;            margin-top: 1px;        }                /* Checked Big Knob (Blue Style) */        input[type="checkbox"].bigswitch.ios-switch:checked + div > div        {            -webkit-transform: translate3d(25px, 0, 0);            -moz-transform: translate3d(16px, 0, 0);            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3), 0px 0px 0 1px rgba(8, 80, 172,1);        }                /* Green Knob */        input[type="checkbox"].green.ios-switch:checked + div > div        {            box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 162, 63,1);        }                /* Needless Page Decoration */        body        {            -webkit-user-select: none;            cursor: default;            font: 18px "Helvetica Neue";            color: rgba(0, 0, 0, 0.77);            font-weight: 200;            padding-left: 30px;            padding-top: 0px;            background: -webkit-linear-gradient(top, #f2fbff 0%, #ffffff 64%) no-repeat;            background: -moz-linear-gradient(top, #f2fbff 0%, #ffffff 64%) no-repeat;            background: -ms-linear-gradient(top, #f2fbff 0%, #ffffff 64%) no-repeat;            background: linear-gradient(to bottom, #f2fbff 0%, #ffffff 64%) no-repeat;        }        h1        {            font-weight: 100;            font-size: 40px;            color: #135ae4;        }        h2        {            font-weight: 200;            font-size: 22px;            color: #03b000;        }        h3        {            font-weight: 200;            font-size: 18px;            color: rgba(0, 0, 0, 0.77);            margin-top: 50px;        }        a:link        {            text-decoration: none;            color: #f06;        }        a:visited        {            text-decoration: none;            color: #f06;        }        a:hover        {            text-decoration: underline;        }        a:active        {            text-decoration: underline;        }

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
java连接字符串方法汇总
java连接字符串方法汇总

本专题整合了java连接字符串教程合集,阅读专题下面的文章了解更多详细操作。

7

2026.02.05

java中fail含义
java中fail含义

本专题整合了java中fail的含义、作用相关内容,阅读专题下面的文章了解更多详细内容。

8

2026.02.05

控制反转和依赖注入区别
控制反转和依赖注入区别

本专题整合了控制反转和依赖注入区别、解释、实现方法相关内容。阅读专题下面的文章了解更多详细教程。

11

2026.02.05

钉钉脑图插图教程合集
钉钉脑图插图教程合集

本专题整合了钉钉脑图怎么插入图片、钉钉脑图怎么用相关教程,阅读专题下面的文章了解更多详细内容。

24

2026.02.05

python截取字符串方法汇总
python截取字符串方法汇总

本专题整合了python截取字符串方法相关合集,阅读专题下面的文章了解更多详细内容。

2

2026.02.05

Java截取字符串方法合集
Java截取字符串方法合集

本专题整合了Java截取字符串方法汇总,阅读专题下面的文章了解更多详细操作教程。

1

2026.02.05

java 抽象方法
java 抽象方法

本专题整合了java抽象方法定义、作用教程等内容,阅读专题下面的文章了解更多详细内容。

2

2026.02.05

Eclipse创建jsp文件教程合集
Eclipse创建jsp文件教程合集

本专题整合了Eclipse创建jsp文件、创建jsp项目等等内容,阅读专题下面的文章了解更多详细教程。

26

2026.02.05

java 字符串转数字
java 字符串转数字

本专题整合了java如何字符串转数字相关内容,阅读专题下面的文章了解更多详细教程。

4

2026.02.05

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号