一款纯css3实现简单的checkbox复选框和radio单选框

所属分类: 网页制作 / CSS 阅读数: 854
收藏 0 赞 0 分享

  昨天为大家分享了一款很炫的checkbox复选框和radio单选框,今天再给大家带来一款简单实用的checkbox复选框和radio单选框。界面清淅、舒服。先给大家来张效果图:

  实现代码:

  html代码:

XML/HTML Code复制内容到剪贴板
  1. <div class="frame">  
  2.         <input checked="checked" id="radio_1" name="radio" type="radio">  
  3.         <label class="radio" for="radio_1">  
  4.             <i class="fa fa-times"></i>  
  5.         </label>  
  6.         <input id="radio_2" name="radio" type="radio">  
  7.         <label class="radio" for="radio_2">  
  8.             <i class="fa fa-times"></i>  
  9.         </label>  
  10.         <input id="radio_3" name="radio" type="radio">  
  11.         <label class="radio" for="radio_3">  
  12.             <i class="fa fa-times"></i>  
  13.         </label>  
  14.         <input id="radio_4" name="radio" type="radio">  
  15.         <label class="radio" for="radio_4">  
  16.             <i class="fa fa-times"></i>  
  17.         </label>  
  18.         <input id="radio_5" name="radio" type="radio">  
  19.         <label class="radio" for="radio_5">  
  20.             <i class="fa fa-times"></i>  
  21.         </label>  
  22.     </div>  
  23.     <div class="frame">  
  24.         <input checked="checked" id="check_1" name="check" type="checkbox">  
  25.         <label class="check" for="check_1">  
  26.             <i class="fa fa-check"></i>  
  27.         </label>  
  28.         <input id="check_2" name="check" type="checkbox">  
  29.         <label class="check" for="check_2">  
  30.             <i class="fa fa-check"></i>  
  31.         </label>  
  32.         <input id="check_3" name="check" type="checkbox">  
  33.         <label class="check" for="check_3">  
  34.             <i class="fa fa-check"></i>  
  35.         </label>  
  36.         <input id="check_4" name="check" type="checkbox">  
  37.         <label class="check" for="check_4">  
  38.             <i class="fa fa-check"></i>  
  39.         </label>  
  40.         <input id="check_5" name="check" type="checkbox">  
  41.         <label class="check" for="check_5">  
  42.             <i class="fa fa-check"></i>  
  43.         </label>  
  44.     </div>  

  css3代码:

CSS Code复制内容到剪贴板
  1. form   
  2.         {   
  3.             width: 100vw;   
  4.             height: 100vh;   
  5.             display: flex;   
  6.             flex-flow: column wrap;   
  7.             justify-contentcenter;   
  8.             align-items: center;   
  9.         }   
  10.         form .frame   
  11.         {   
  12.             display: flex;   
  13.             flex-flow: row nowrap;   
  14.         }   
  15.         form .frame input   
  16.         {   
  17.             displaynone;   
  18.         }   
  19.         form .frame label   
  20.         {   
  21.             cursorpointer;   
  22.             positionrelative;   
  23.             width30px;   
  24.             height30px;   
  25.             margin10px;   
  26.             background#8ABA56;   
  27.             transition: all 0.3s ease-in-out;   
  28.             font-size12pt;   
  29.             color#FFF;   
  30.             -webkit-font-smoothing: antialiased;   
  31.         }   
  32.         form .frame label.radio   
  33.         {   
  34.             border-radius: 100%;   
  35.         }   
  36.         form .frame label.check   
  37.         {   
  38.             border-radius: 5px;   
  39.         }   
  40.         form .frame label .fa   
  41.         {   
  42.             positionabsolute;   
  43.             top: 0;   
  44.             left: 0;   
  45.             rightright: 0;   
  46.             bottombottom: 0;   
  47.             opacity: 0;   
  48.             -webkit-transform: scale(0);   
  49.             transition: all 0.3s ease-in-out;   
  50.             line-height30px;   
  51.             text-aligncenter;   
  52.         }   
  53.         form .frame input:checked + label   
  54.         {   
  55.             background#678b40;   
  56.         }   
  57.         form .frame input:checked + label .fa   
  58.         {   
  59.             opacity: 1;   
  60.             -webkit-transform: scale(1);   
  61.         }  

  好了。复制上面的html代码和css代码。轻松搞定一款漂亮的checkbox、radio按钮,谢谢阅读,希望能帮到大家,请继续关注脚本之家,我们会努力分享更多优秀的文章。

更多精彩内容其他人还在看

CSS样式分离之再分离达到精简与重用

无论是CSS的分离还是js的分离,其主要作用之一就是精简与重用,CSS本身就代表着精简与重用,CSS样式分离,我一般指的是“以单独的CSS文件将CSS样式分离出来”,此处的重用多针对不同页面的重用,就是说,一个样式文件,可以多个页面使用,这对于一些公共样式的重构是很有
收藏 0 赞 0 分享

CSS属性behavior的语法使用说明

在进行CSS网页布局的时候,我们经遇到刷新要保留表单里内容的时候,习惯的做法使用cookie,但是那样做实在是很麻烦,css中的behavior就为我们很好的解决了这个问题。今天jb51.net就向大家介绍CSS属性behavior的语法
收藏 0 赞 0 分享

网页制作中的水平居中和垂直居中解决方法集合

 在定义网页的CSS样式的时候,我们或许并不怎么用到垂直居中。
收藏 0 赞 0 分享

最常见IE的Bug及其fix修复方法

Internet Explorer – Web程序员的毒药。在IE上开发时间中有超过60%的时间是花在和IE的bug进行搏斗,让你的开发生产率严重下降。下面是一个教程,告诉你9个IE上最常见的BUG以及如何解决它们。
收藏 0 赞 0 分享

CSS常用浏览器兼容调整小结

用CSS+DIV来写网站代码的好处显而易见,这里不多说了,但由于不同浏览器对CSS的解释不统一,造成不同浏览器下页面错位的现象十分常见……
收藏 0 赞 0 分享

css firefox火狐浏览器下的兼容性问题

css firefox火狐浏览器下的兼容性问题
收藏 0 赞 0 分享

DIV+CSS 浏览器兼容性小结

在网站设计的时候,应该注意css样式兼容不同浏览器问题,特别是对完全使用DIV CSS设计的网,就应该更注意IE6 IE7 FF对CSS样式的兼容,不然,你的网乱可能出去不想出现的效果!
收藏 0 赞 0 分享

div+css 布局常识 8问

CSSer与其他IT职位一样,在找工作的时候,都会面临着面试官提出的问题,或者给出的试卷。今天jb51.net收集了常见的8条面试题目,希望对您有所帮助。
收藏 0 赞 0 分享

CSS用四种方式实现布局

CSS用四种方式实现布局
收藏 0 赞 0 分享

css 解决表格边框不显示的问题

在 IE6 中,当表格单元格中的数据为空时,边框是不显示的,在IE8中是会显示的,怎样解决这个不兼容的问题呢。
收藏 0 赞 0 分享
查看更多