CSS3复选框动画
本示例实现了两种单选按钮动画效果,一种是移动,一种是滑块,以下是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复选框动画的更多相关文章
- 8个非常个性化的CSS3单/复选框
单选框和复选框在网页表单中应用十分广泛,但是浏览器默认自带的单选框和复选框样式不仅不统一,而且大多都比较简单丑陋.本文给大家介绍了一些基于CSS3的个性化单选框和复选框,一些选中动画是基于jQuery ...
- 基于CSS3自定义美化复选框Checkbox组合
今天我们要来分享一组非常漂亮的CSS3自定义复选框checkbox,每一个checkbox都有其各自的特点.有几款checkbox在选中的情况下还会出现动画效果,非常不错的CSS3自定义美化check ...
- 纯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 ...
- anime.js 实战:实现一个带有描边动画效果的复选框
在网页或者是APP的开发中,动画运用得当可以起到锦上添花的作用.正确使用动画,不但可以有助于用户理解交互的作用,还可以大大提高网页应用的魅力和使用体验.并且在现在的网页开发中,动画已经成为了一个设计的 ...
- css3美化复选框checkbox
两种美化效果如下图: 代码(html) <div id="main"> <h2 class="top_title">使用CSS3美化复 ...
- 使用CSS3美化复选框checkbox
我们知道HTML默认的复选框样式十分简陋,而以图片代替复选框的美化方式会给页面表单的处理带来麻烦,那么本文将结合实例带您一起了解一下使用CSS3将复选框checkbox进行样式美化,并且带上超酷的滑动 ...
- iOS Instruments之Core Animation动画性能调优(工具复选框选项介绍)
Core Animation工具用来监测Core Animation性能.它给我们提供了周期性的FPS,并且考虑到了发生在程序之外的动画(见图12.4) Core Animation工具提供了一系列复 ...
- CSS效果:这里有你想要的CSS3漂亮的自定义Checkbox各种复选框
在原来有一篇文章写到了<CSS效果篇--纯CSS+HTML实现checkbox的思路与实例>. 今天这篇文章主要写各种自定义的checkbox复选框,实现如图所示的复选框: 大致的html ...
- 使用css3美化复选框
声明:文章为转载(略改动),点击查看原文.如有侵权24小时内删除,联系QQ:1522025433. 我们知道HTML默认的复选框样式十分简陋,而以图片代替复选框的美化方式会给页面表单的处理带来麻烦,那 ...
随机推荐
- 安卓Socket开发注意事项
如果要在安卓app里用到Socket通信,要满足: 1.在写代码的activity里import进Socket相关的包,这个很easy,如果你不知道要import什么包,也可以先不指定,可 ...
- IOS GCDAsyncSocket
// // ViewController.m // 05.聊天室 // // Created by apple on 14/12/5. // Copyright (c) 2014年 heima. Al ...
- mysqlbinlog用法总结
通过binlog日志统计dml语句,找出操作频繁的表 mysqlbinlog --no-defaults --base64-output=decode-rows -v -v mysql-bin.0 ...
- pthread_create & pthread_exit
http://www.cppblog.com/saha/articles/189802.html 1. pthread_create #include <pthread.h> ...
- 使用ToDateTime方法转换日期显示格式
实现效果: 知识运用: Convert类的ToDateTime方法:(将字符串转化为DateTime对象) public static DateTime ToDateTime(string value ...
- 从命令行运行Jmeter及jmeter参数说明、Html报告生成
为什么要命令行执行脚本,主要有以下三点: 1) 图形化界面消耗更多资源,CPU和内存 2) 图形化界面不支持大型的负载测试和性能测试 3) 命令行测试支持持续集成,例如放到Jenkins这样的CI工具 ...
- ASP.NET SignalR 与LayIM配合,轻松实现网站客服聊天室(三) 激动人心的时刻到啦,实现1v1聊天
看起来挺简单,细节还是很多的,好,接上一篇,我们已经成功连接singalR服务器了,那么剩下的内容呢,就是一步一步实现聊天功能. 我们先看看缺什么东西 点击好友弹框之后,要给服务器发消息,进入组Gro ...
- 一组div跟随鼠标移动,反应鼠标轨迹
<!DOCTYPE html> <html> <head> <title>div随鼠标移动</title> <style type=& ...
- Python-time和datetime模块
一.time模块 1.表示时间的三种方式 >>> import time >>> time.time() #当前时间戳 1509525556.8485825 > ...
- 【luogu P3807 卢卡斯定理】 模板
题目链接:https://www.luogu.org/problemnew/show/P3807 Lucas定理用来求大组合数对一个质数取模的值,不大于10^5用逆元,大于10^5就用Lucas转化成 ...