表单/表格

Material Design 风格单复选框动画特效

阿里云


这是一款效果非常炫酷的纯 CSS3 Material Design 风格单选按钮和复选框动画特效。该特效使用 CSS 帧动画来在单选按钮或复选框被选择时制作类似于按钮点击波的效果。它的代码简洁,效果非常的出色。遗憾的是,目前只有谷歌浏览器支持这一特效,在不支持该特效的浏览器上,单选按钮和复选框也被进行了一些美化,整体还是不错的。

HTML 结构

该特效的复选框和单选按钮的 HTML 结构都是使用一个

也想出现在这里?联系我们
创客主机
  1. <label>
  2.   <input type="checkbox" class="option-input checkbox" CHECKED />
  3.   Checkbox
  4. </label>
  5. <label>
  6.   <input type="radio" class="option-input radio" name="example" />
  7.   Radio option
  8. </label>

CSS 样式

单选按钮和复选框的基本样式如下,其中::before 伪元素用于制作单选按钮和复选框中的小叉,::after 伪元素用于制作点击波动画效果。

  1. .option-input {
  2.   -webkit-appearance: none;
  3.   -moz-appearance: none;
  4.   -ms-appearance: none;
  5.   -o-appearance: none;
  6.   appearance: none;
  7.   position: relative;
  8.   top: 13.33333px;
  9.   width: 40px;
  10.   height: 40px;
  11.   -webkit-transition: all 0.15s ease-out 0;
  12.   -moz-transition: all 0.15s ease-out 0;
  13.   transition: all 0.15s ease-out 0;
  14.   background: #cbd1d8;
  15.   border: none;
  16.   color: #fff;
  17.   cursor: pointer;
  18.   display: inline-block;
  19.   outline: none;
  20.   position: relative;
  21.   margin-right: 0.5rem;
  22.   z-index: 1000;
  23. } 
  24. .option-input:hover { background: #9faab7; }
  25. .option-input:checked { background: #40e0d0; }
  26. .option-input:checked::before {
  27.   width: 40px;
  28.   height: 40px;
  29.   position: absolute;
  30.   content: '\2716';
  31.   display: inline-block;
  32.   font-size: 26.66667px;
  33.   text-align: center;
  34.   line-height: 40px;
  35. }
  36.  
  37. .option-input:checked::after {
  38.   -webkit-animation: click-wave 0.65s;
  39.   -moz-animation: click-wave 0.65s;
  40.   animation: click-wave 0.65s;
  41.   background: #40e0d0;
  42.   content: '';
  43.   display: block;
  44.   position: relative;
  45.   z-index: 100;
  46. }
  47. .option-input.radio { border-radius: 50%; }
  48. .option-input.radio::after { border-radius: 50%; }

然后使用 CSS keyframe 来制作 Material Design 风格的按钮点击波特效。

  1. @-webkit-keyframes 
  2. click-wave { 0% {
  3.  width: 40px;
  4.  height: 40px;
  5.  opacity: 0.35;
  6.  position: relative;
  7. }
  8.  100% {
  9.  width: 200px;
  10.  height: 200px;
  11.  margin-left: -80px;
  12.  margin-top: -80px;
  13.  opacity: 0.0;
  14. }
  15. }
  16.  
  17. @-moz-keyframes 
  18. click-wave { 0% {
  19.  width: 40px;
  20.  height: 40px;
  21.  opacity: 0.35;
  22.  position: relative;
  23. }
  24.  100% {
  25.  width: 200px;
  26.  height: 200px;
  27.  margin-left: -80px;
  28.  margin-top: -80px;
  29.  opacity: 0.0;
  30. }
  31. }
  32.  
  33. @-o-keyframes 
  34. click-wave { 0% {
  35.  width: 40px;
  36.  height: 40px;
  37.  opacity: 0.35;
  38.  position: relative;
  39. }
  40.  100% {
  41.  width: 200px;
  42.  height: 200px;
  43.  margin-left: -80px;
  44.  margin-top: -80px;
  45.  opacity: 0.0;
  46. }
  47. }
  48.  
  49. @keyframes 
  50. click-wave { 0% {
  51.  width: 40px;
  52.  height: 40px;
  53.  opacity: 0.35;
  54.  position: relative;
  55. }
  56.  100% {
  57.  width: 200px;
  58.  height: 200px;
  59.  margin-left: -80px;
  60.  margin-top: -80px;
  61.  opacity: 0.0;
  62. }
  63. }

Material Design 风格单复选框动画特效

已有 291 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!