本示例实现了两种单选按钮动画效果,一种是移动,一种是滑块,以下是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. [EffectiveC++]item31:将文件间的编译依存关系降至最低

    P143:“声明的依赖性"替换“定义的依存性”

  2. com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException 异常

    MySQL完整性约束破坏异常:com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException 在单向多对一关联关系 ...

  3. ACM-ICPC (10/19)

    这两天在看虚树,的确很难理解. 不过大致的思路就是说删掉一些没有用的点,但是仍然保持树的相对结构,树上只有两种点,一个是集合点,和一些LCA,这些LCA是为了保持树的相对结构,才留下的. 具体做法网上 ...

  4. Object c的NSString的使用,创建,拼接和分隔,子string,substring

    main: // //  main.m //  StringDemo // //  Created by 千 on 16/9/22. //  Copyright © 2016年 kodulf. All ...

  5. AIM Tech Round 5 (rated, Div. 1 + Div. 2) C. Rectangles 【矩阵交集】

    题目传传传送门:http://codeforces.com/contest/1028/problem/C C. Rectangles time limit per test 2 seconds mem ...

  6. PHP设计模式——观察者模式

    PHP版本 <?php /** * 观察者模式 * 观察者模式能够便利的创建查看目标对象状态的对象,并且提供与核心对象非耦合的指定性功能. * * 为软件添加由某个动作或状态变化激活的,但是松散 ...

  7. 2018.9.28 典型for循环特殊理解及其二维数组的理解

    如果for里面换成了函数结果会是怎么样呢?下面就来介绍一下 package praDemo; public class Test { public static boolean foo(char c) ...

  8. prior_box层

    https://www.jianshu.com/p/5195165bbd06 1.step_w.step_h其实就相当于faster中的feat_stride,也就是把这些点从feature map映 ...

  9. 【luogu P1314 聪明的质监员】 题解

    题目链接:https://www.luogu.org/problemnew/show/P1314 二分答案 但是计算区间贡献的时候 直接暴力会挂 前缀和加速 #include <cstdio&g ...

  10. 【luogu P3063 [USACO12DEC]牛奶的路由Milk Routing】 题解

    题目链接:https://www.luogu.org/problemnew/show/P3063#sub 我很好奇这道题为什么没被收入SPFA好题 #include <cstdio> #i ...