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

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

分类:CSS_CSS3 答疑 - 常见问题 · 发布时间:2021-10-02 04:30 · 阅读:4932

这篇文章主要为大家介绍了利用纯css3实现一款简单实用的checkbox复选框和radio单选框,代码简单易懂,可以直接复制,感兴趣的可以进来看看哦

  昨天为大家分享了一款很炫的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.         }  

标签:
纯CSS3 复选框

相关文章

css3媒体查询中device-width和width的区别详解

这篇文章主要介绍了css3媒体查询中device-width和width的区别详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

CSS3媒体查询实现不同宽度的下不同内容的展示功能

这篇文章主要介绍了CSS3媒体查询实现不同宽度的下不同内容的展示功能,本章节我们将为大家演示一些多媒体查询实例,需要的朋友可以参考下

CSS3几种实现子容器水平垂直居中的方法

本文有几种方法可以实现容器与子容器水平垂直居中,主要包括Flexbox布局,position绝对定位+transform,表格布局,具有一定的参考价值,感兴趣的可以了解一下

css3实现文字首尾衔接跑马灯的示例代码

这篇文章主要介绍了css3实现文字首尾衔接跑马灯的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

CSS的浮动及清除浮动的5种方法介绍

这篇文章主要为大家介绍了CSS的浮动及清除浮动的5种方法介绍,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪

返回分类 返回首页