本示例实现了两种单选按钮动画效果,一种是移动,一种是滑块,以下是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. Git warning push.default is unset

    warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple ...

  2. ccsu小助手

    CCSU小助手 队名:瓜队 组员:钟文兴.周畅.吉刘磊.唐仲勋 宣言:We are a team at any time! 团队项目描述: 内容:“生活在长大”: 目标:为了方便对学校不了解的学生能够 ...

  3. Scrum第三次冲刺

    1.第三次冲刺任务概述 我们设计的长大万能通系统主要实现以下几个功能: a.周边查询 b.快递代取 c.查看校内新闻动态 d.二手物品交易 第三次冲刺我们计划实现周边查询功能.可以根据评分.距离最近. ...

  4. js数据封装处理

    var arr = [ { id: "1", date: "2018-07-27", time: "10:00-12:00", schedu ...

  5. Jmeter入门2 http请求—简单的get请求

    发送一个简单的get http请求 1 启动Jmeter,在测试计划上点击鼠标右键>添加>Threads(Users)>线程组 2 线程组界面.可设置线程数,几秒启动所有线程,循环次 ...

  6. Ubuntu环境安装Gradle

    AndroidStudio使用全新的构建系列—–Gradle. 这是官方为什么使用gradle 的理由: Domain Specific Language (DSL) to describe and ...

  7. Velocity 模板

    Velocity 模板引擎介绍 引:https://www.ibm.com/developerworks/cn/java/j-lo-velocity1/ 在 现今的软件开发过程中,软件开发人员将更多的 ...

  8. 作为PHP开发者请务必了解Composer

    Composer是一个非常流行的PHP包依赖管理工具,已经取代PEAR包管理器,对于PHP开发者来说掌握Composer是必须的. 对于使用者来说Composer非常的简单,通过简单的一条命令将需要的 ...

  9. 关于A*估价函数的总结

    估价函数的优劣决定一个A*算法的好坏 360百科上是这样说的: (https://baike.so.com/doc/6223470-6436780.html) 关于估价函数h(n)与实际距离d(n)的 ...

  10. HDU 2199 Can you solve this equation?(二分解方程)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/10 ...