今天给大家介绍一款仿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开关按钮的更多相关文章

  1. 一款仿PBA官网首页jQuery焦点图的切换特效

    一款仿PBA官网首页jQuery焦点图的切换特效,非常的简单大方, 在对浏览器兼容性的方面做了不少的功夫.IE6也勉强能过去. 还是一款全屏的焦点图切换特效.大气而清新.很适合简介大方的网站. 下图还 ...

  2. 做一款仿映客的直播App

    投稿文章,作者:JIAAIR(GitHub) 一.直播现状简介 1.技术实现层面 技术相对都比较成熟,设备也都支持硬编码.iOS还提供现成的Video ToolBox框架,可以对摄像头和流媒体数据结构 ...

  3. 做一款仿映客的直播App?看我就够了

    来源:JIAAIR 链接:http://www.jianshu.com/p/5b1341e97757 一.直播现状简介   1.技术实现层面: 技术相对都比较成熟,设备也都支持硬编码.IOS还提供现成 ...

  4. iBox v2.0 发布,Web化仿iOS7界面/交互的JavaScirpt库

    iBox2 是一个仿 iOS 7 界面/交互的 JavaScirpt 库,它运行在 webkit 内核的移动浏览器之上,依赖 iScroll5,帮助开发者构建更接近 iOS 体验的 WebApp. 伴 ...

  5. 【推荐】免费,19 款仿 Bootstrap 后台管理主题下载

    声明: 1. 本篇文章提到的仿 Bootstrap 风格的主题,是基于 jQuery 的 ASP.NET MVC 控件库的主题. 2. FineUIMvc(基础版)完全免费,可以用于商业项目. 目录 ...

  6. 仿IOS7日期选择控件(新)

    前面也写过好几篇仿IOS日期控件的文章,不过基本上都是基于Wheelview修改而来,大致实现了滑轮选择选项的效果,其实和ios7及以上的效果还是相差甚远,而本文中所展现的这个控件虽也是从网上而来(呵 ...

  7. 19 款仿 Bootstrap 后台管理主题免费下载

    声明: 1. 本篇文章提到的仿 Bootstrap 风格的主题,是基于 jQuery 的 ASP.NET MVC 控件库的主题. 2. FineUIMvc(基础版)完全免费,可以用于商业项目. 目录 ...

  8. 一款仿36氪iOS版APP源码

    Features 离线缓存 解决视频播放器的网速慢卡顿 视频播放器调用简单 cell自适应高度 cell中嵌套webView cell中嵌套webView 条件实时搜索 Known problems ...

  9. Handsontable-一款仿 Excel效果的表格插件使用总结 96

    最近在做一个关于报表管理的项目,发现了一款很好用的jQuery插件-Handsontable.它真的特别给力,在 Excel 中可进行的操作,你几乎都可以在网页中做到,如拖动复制.Ctrl+C .Ct ...

随机推荐

  1. java 关于操作Collection的一点说明

    java 中有一个工具类 Collections 其中的一个方法 static <T> boolean replaceAll(List<T> list, T oldVal, T ...

  2. oracle中number对应java数据类型

    本文转自:http://blog.csdn.net/ludongshun2016/article/details/71453125 数据库中为number类型的字段,在Java类型中对应的有Integ ...

  3. 【LeetCode】140. Word Break II

    Word Break II Given a string s and a dictionary of words dict, add spaces in s to construct a senten ...

  4. PLSQL连接ORACLE配置字符串简介 oracle网络配置 三个配置文件 listener.ora、sqlnet.ora、tnsnames.ora原理解释

    PLSQL连接ORACLE配置字符串简介 oracle网络配置 三个配置文件 listener.ora.sqlnet.ora.tnsnames.ora原理解释 oracle网络配置三个配置文件 lis ...

  5. ubuntu(14.04) 安装ssh,并使用root用户登录

    1.apt-get install openssh-server 2.修改ssh的配置文件/etc/ssh/sshd_config 注释掉以前的:PermitRootLogin without-pas ...

  6. if you are not making someone else's life better, then you are wasting your time.– Will Smith如果你不能给别人的生活带来改善,那么你就是在浪费你的宝贵时间。 --威尔 史密斯(程序员,你做的东西...)

    if you are not making someone else's life better, then you are wasting your time. – Will Smith 如果你不能 ...

  7. 工作总结 public DateTime? CollectionTime 可空类型 Code First

    数据库生成就对应生成  可以为空 的字段

  8. 搭建Selenium-Grid环境

    转帖 在搭建Selenium-Grid之前,首先要搭建每台测试机上的Selenium环境: 安装Java 配置Java环境变量 下载ie.chrome的driver程序[如果要测试其它浏览器还需额外下 ...

  9. CodeForces 445B. DZY Loves Chemistry(并查集)

    转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://codeforces.com/problemset/prob ...

  10. HDU 5092 DP

    DP水题 求从上到下走完,使所取得权值最小,并输出路径,若有多个满足,则输出靠右的 #include "stdio.h" #include "string.h" ...