本示例实现了两种单选按钮动画效果,一种是移动,一种是滑块,以下是html布局以及css样式

html:这里使用了label标签的for属性,以此来绑定radio

<div class="checkbox-1">
<input type="checkbox" name="checkbox-1" id="checkbox-1-1" checked="checked">
<label for="checkbox-1-1"></label> <input type="checkbox" name="checkbox-1" id="checkbox-1-2">
<label for="checkbox-1-2"></label> <input type="checkbox" name="checkbox-1" id="checkbox-1-3">
<label for="checkbox-1-3"></label>
</div>
<div class="checkbox-2">
<input type="checkbox" name="checkbox-2" id="checkbox-2-1" checked="checked">
<label for="checkbox-2-1"></label> <input type="checkbox" name="checkbox-2" id="checkbox-2-2">
<label for="checkbox-2-2"></label> <input type="checkbox" name="checkbox-2" id="checkbox-2-3">
<label for="checkbox-2-3"></label>
</div>

css

<style type="text/css">
.checkbox-1{
width: 980px;
margin: 0 auto;
text-align: center;
padding: 3% 0;
background-color: #99cccc;
}
.checkbox-1 label{
display: inline-block;
width: 10px;
height: 10px;
padding: 9px;
border: 1px #cccccc solid;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
background-color: #ffffff;
color: #333;
margin-right: 10px;
overflow: hidden;
position: relative;
cursor: pointer;
}
.checkbox-1 [type="checkbox"]{
display: none;
}
.checkbox-1 label:after{
content: 'X';
font-family: Arial;
color: #ffffff;
background-color: #399;
position: absolute;
top: 1px;
left: 1px;
width: 26px;
height: 26px;
line-height: 26px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
text-align: center;
-webkit-transform: translateY(-30px);
-moz-transform: translateY(-30px);
-ms-transform: translateY(-30px);
-o-transform: translateY(-30px);
transform: translateY(-30px);
-webkit-transition: -webkit-transform .2s ease-in;
-moz-transition: -moz-transform .2s ease-in;
-ms-transition: -ms-transform .2s ease-in;
-o-transition: -o-transform .2s ease-in;
transition: transform .2s ease-in;
}
.checkbox-1 [type="checkbox"]:checked + label:after{
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
-ms-transform: translateY(0);
-o-transform: translateY(0);
transform: translateY(0);
-webkit-transition: -webkit-transform .2s ease-in;
-moz-transition: -moz-transform .2s ease-in;
-ms-transition: -ms-transform .2s ease-in;
-o-transition: -o-transform .2s ease-in;
transition: transform .2s ease-in;
} .checkbox-2{
width: 980px;
margin: 0 auto;
text-align: center;
padding: 3% 0;
background-color: #99cccc;
}
.checkbox-2 label{
display: inline-block;
width: 68px;
height: 34px;
border: 1px #cccccc solid;
-webkit-border-radius: 18px;
-moz-border-radius: 18px;
border-radius: 18px;
background-color: #ffffff;
margin-right: 10px;
position: relative;
cursor: pointer;
-webkit-transition: background-color .2s ease-in;
-moz-transition: background-color .2s ease-in;
-ms-transition: background-color .2s ease-in;
-o-transition: background-color .2s ease-in;
transition: background-color .2s ease-in;
}
.checkbox-2 [type="checkbox"]{
display: none;
}
.checkbox-2 label:after{
content: '';
position: absolute;
left: 1px;
top: 1px;
width: 30px;
height: 30px;
border: 1px #e0e0e0 solid;
background-color: #ffffff;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
-webkit-transition: left .2s ease-in;
-moz-transition: left .2s ease-in;
-ms-transition: left .2s ease-in;
-o-transition: left .2s ease-in;
transition: left .2s ease-in;
}
.checkbox-2 [type="checkbox"]:checked + label{
background-color: #33cc66;
-webkit-transition: background-color .2s ease-in;
-moz-transition: background-color .2s ease-in;
-ms-transition: background-color .2s ease-in;
-o-transition: background-color .2s ease-in;
transition: background-color .2s ease-in;
}
.checkbox-2 [type="checkbox"]:checked + label:after{
left: 35px;
-webkit-transition: left .2s ease-in;
-moz-transition: left .2s ease-in;
-ms-transition: left .2s ease-in;
-o-transition: left .2s ease-in;
transition: left .2s ease-in;
}
</style>

CSS3复选框动画的更多相关文章

  1. 8个非常个性化的CSS3单/复选框

    单选框和复选框在网页表单中应用十分广泛,但是浏览器默认自带的单选框和复选框样式不仅不统一,而且大多都比较简单丑陋.本文给大家介绍了一些基于CSS3的个性化单选框和复选框,一些选中动画是基于jQuery ...

  2. 基于CSS3自定义美化复选框Checkbox组合

    今天我们要来分享一组非常漂亮的CSS3自定义复选框checkbox,每一个checkbox都有其各自的特点.有几款checkbox在选中的情况下还会出现动画效果,非常不错的CSS3自定义美化check ...

  3. 纯CSS3来自定义单选框radio与复选框checkbox

    单选框(radio)自定义样式 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 ...

  4. anime.js 实战:实现一个带有描边动画效果的复选框

    在网页或者是APP的开发中,动画运用得当可以起到锦上添花的作用.正确使用动画,不但可以有助于用户理解交互的作用,还可以大大提高网页应用的魅力和使用体验.并且在现在的网页开发中,动画已经成为了一个设计的 ...

  5. css3美化复选框checkbox

     两种美化效果如下图: 代码(html) <div id="main"> <h2 class="top_title">使用CSS3美化复 ...

  6. 使用CSS3美化复选框checkbox

    我们知道HTML默认的复选框样式十分简陋,而以图片代替复选框的美化方式会给页面表单的处理带来麻烦,那么本文将结合实例带您一起了解一下使用CSS3将复选框checkbox进行样式美化,并且带上超酷的滑动 ...

  7. iOS Instruments之Core Animation动画性能调优(工具复选框选项介绍)

    Core Animation工具用来监测Core Animation性能.它给我们提供了周期性的FPS,并且考虑到了发生在程序之外的动画(见图12.4) Core Animation工具提供了一系列复 ...

  8. CSS效果:这里有你想要的CSS3漂亮的自定义Checkbox各种复选框

    在原来有一篇文章写到了<CSS效果篇--纯CSS+HTML实现checkbox的思路与实例>. 今天这篇文章主要写各种自定义的checkbox复选框,实现如图所示的复选框: 大致的html ...

  9. 使用css3美化复选框

    声明:文章为转载(略改动),点击查看原文.如有侵权24小时内删除,联系QQ:1522025433. 我们知道HTML默认的复选框样式十分简陋,而以图片代替复选框的美化方式会给页面表单的处理带来麻烦,那 ...

随机推荐

  1. [原] Android自动打包之命令行打包

    Android自动打包流程详细图: 总结为以下几个步骤: 1. 生成R文件 2. Java代码编译成class文件 3. class文件生成dex文件 4. 打包资源 5. 生成apk 6. 创建密匙 ...

  2. [转]Ubuntu 小企鹅输入法fcitx 支持 五笔拼音

    之前在Ubuntu下使用ibus五笔输入法,用了一段时间发现五笔输入法不能输入词组,并且五笔不支持拼音的功能,从网上找到可以使用fcitx替换掉ibus,因此自已尝试了一把,安装步骤如下: 1. 安装 ...

  3. 问题 A: B 继承 圆到圆柱体

    题目描述 定义了Circle圆形类,在此基础上派生出Cylinder圆柱体类. Circle圆形类定义如下: class Circle { public: Circle(double r):radiu ...

  4. 【iOS】那些年,遇到的小坑

    'NSInvalidArgumentException', reason: '-[__NSPlaceholderDictionary initWithObjectsAndKeys:]: second ...

  5. Array GCD CodeForces - 624D (dp,gcd)

    大意: 给定序列, 给定常数a,b, 两种操作, (1)任选一个长为$t$的子区间删除(不能全部删除), 花费t*a. (2)任选$t$个元素+1/-1, 花费t*b. 求使整个序列gcd>1的 ...

  6. JS获取浏览器高度和宽度

    IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.d ...

  7. C#实现打印

    C#实现导出pdf文件,打印 using System; using System.Collections.Generic; using System.Linq; using System.Web; ...

  8. Hibernate知识点小结(一)--快速入门

    一.Hibernate的简介    1.Hibernate是一个开放源代码的对象关系映射框架    2.对象关系映射:ORM  Object Relation Mapping        对象与数据 ...

  9. react中图片校验码实现以及new Buffer()使用方法

    图片校验码原理就是图片是后端生成的前端只是前后端传过来的数据流做些处理展示即可,先直接上核心代码图: 这里就是简单得对axios的一些默认项属性重写:最后你只需要将resolve的内容插入页面的< ...

  10. iframe优缺点

    优点:重载页面时不需要重载整个页面,只需要重载页面中的一个框架页(减少了数据的传输,加快了网页下载速度)