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

实现的代码。
html代码:
<div class="wrap" style="width: 600px; margin: auto;">
<h1>
iOS 7 style switches with CSS</h1>
<h2>
By Bandar Raffah</h2>
<label>
Big<input type="checkbox" class="ios-switch green bigswitch" checked /><div>
<div>
</div>
</div>
</label>
<label>
<input type="checkbox" class="ios-switch bigswitch" checked /><div>
<div>
</div>
</div>
</label>
<label>
Normal<input type="checkbox" class="ios-switch green" /><div>
<div>
</div>
</div>
</label>
<label>
<input type="checkbox" class="ios-switch" /><div>
<div>
</div>
</div>
</label>
<label>
Tiny<input type="checkbox" class="ios-switch green tinyswitch" checked /><div>
<div>
</div>
</div>
</label>
<label>
<input type="checkbox" class="ios-switch tinyswitch" checked /><div>
<div>
</div>
</div>
</label>
</div>
css代码:
input[type="checkbox"]
{
position: absolute;
opacity:;
} /* 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:;
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:;
font-size: 40px;
color: #135ae4;
}
h2
{
font-weight:;
font-size: 22px;
color: #03b000;
}
h3
{
font-weight:;
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;
}
注:本文爱编程原创文章,转载请注明原文地址:http://www.w2bc.com/Article/8897
一款仿ios7的switches开关按钮的更多相关文章
- 一款仿PBA官网首页jQuery焦点图的切换特效
一款仿PBA官网首页jQuery焦点图的切换特效,非常的简单大方, 在对浏览器兼容性的方面做了不少的功夫.IE6也勉强能过去. 还是一款全屏的焦点图切换特效.大气而清新.很适合简介大方的网站. 下图还 ...
- 做一款仿映客的直播App
投稿文章,作者:JIAAIR(GitHub) 一.直播现状简介 1.技术实现层面 技术相对都比较成熟,设备也都支持硬编码.iOS还提供现成的Video ToolBox框架,可以对摄像头和流媒体数据结构 ...
- 做一款仿映客的直播App?看我就够了
来源:JIAAIR 链接:http://www.jianshu.com/p/5b1341e97757 一.直播现状简介 1.技术实现层面: 技术相对都比较成熟,设备也都支持硬编码.IOS还提供现成 ...
- iBox v2.0 发布,Web化仿iOS7界面/交互的JavaScirpt库
iBox2 是一个仿 iOS 7 界面/交互的 JavaScirpt 库,它运行在 webkit 内核的移动浏览器之上,依赖 iScroll5,帮助开发者构建更接近 iOS 体验的 WebApp. 伴 ...
- 【推荐】免费,19 款仿 Bootstrap 后台管理主题下载
声明: 1. 本篇文章提到的仿 Bootstrap 风格的主题,是基于 jQuery 的 ASP.NET MVC 控件库的主题. 2. FineUIMvc(基础版)完全免费,可以用于商业项目. 目录 ...
- 仿IOS7日期选择控件(新)
前面也写过好几篇仿IOS日期控件的文章,不过基本上都是基于Wheelview修改而来,大致实现了滑轮选择选项的效果,其实和ios7及以上的效果还是相差甚远,而本文中所展现的这个控件虽也是从网上而来(呵 ...
- 19 款仿 Bootstrap 后台管理主题免费下载
声明: 1. 本篇文章提到的仿 Bootstrap 风格的主题,是基于 jQuery 的 ASP.NET MVC 控件库的主题. 2. FineUIMvc(基础版)完全免费,可以用于商业项目. 目录 ...
- 一款仿36氪iOS版APP源码
Features 离线缓存 解决视频播放器的网速慢卡顿 视频播放器调用简单 cell自适应高度 cell中嵌套webView cell中嵌套webView 条件实时搜索 Known problems ...
- Handsontable-一款仿 Excel效果的表格插件使用总结 96
最近在做一个关于报表管理的项目,发现了一款很好用的jQuery插件-Handsontable.它真的特别给力,在 Excel 中可进行的操作,你几乎都可以在网页中做到,如拖动复制.Ctrl+C .Ct ...
随机推荐
- 转:eclipse里面显示中文乱码
显示中文会变成乱码解决方案:Windows- >Pereferences- >General->Workspace- >Text File Encoding 选项下 ...
- 单节点k8s的一个小例子 webapp+mysql
安装kubernetes 准备一台centos7 1) 关闭firewalld 和 selinux systemctl stop firewalld systemctl disable firewal ...
- oracle中number对应java数据类型
本文转自:http://blog.csdn.net/ludongshun2016/article/details/71453125 数据库中为number类型的字段,在Java类型中对应的有Integ ...
- 从使用 KVO 监听 readonly 属性说起
01.KVO 原理 KVO 是 key-value observing 的简写,它的原理大致是: 1.当一个 object(对象) 有观察者时候,动态创建这个 object(对象) 的类的子类(以 N ...
- 【php】基础学习1
其中包括php基础.字符串和正则表达式的学习.具体如下: <html xmlns=http://www.w3.org/1999/xhtml> <head> <meta h ...
- tmux安装
安装tmux sudo yum -y install tmux 修改tmux配置 cat > /root/.tmux.conf <<EOF set-option -g default ...
- GO1.6语言学习笔记1-基础篇
一.GO语言优势 可直接编译成机器码,Go编译生成的是一个静态可执行文件,除了glibc外没有其他外部依赖 静态类型语言,但是有动态语言的感觉 语言层面支持并发.Goroutine和channel ...
- window 环境 Composer 安装 thinkphp5
参考链接:https://www.kancloud.cn/thinkphp/thinkphp5_quickstart/478269 在 Windows 中,你需要下载并运行 Composer-Setu ...
- jenkins 构建执行jmeter测试流程
性能测试使用maven工程说明1.依赖尽量用maven依赖管理2.添加jmeter maven依赖 <dependency> <groupId>org.apache.jmete ...
- js判断字符是否为空的方法
js判断字符是否为空的方法: //判断字符是否为空的方法 function isEmpty(obj){ if(typeof obj == "undefined" || obj == ...