css+js实现炫酷radio单选框点击动画效果代码

代码语言:html

所属分类:表单美化

代码描述:css+js实现炫酷radio单选框点击动画效果代码

代码标签: css js 炫酷 radio 单选框 点击 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">
  

  
  
  
<style>
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@600&display=swap");
body {
  align-items: center;
  display: flex;
  flex-direction: column;
  height: 100vh;
  justify-content: center;
  color: #fff;
  font-family: "Montserrat", sans-serif;
  background: #222;
  height: 100vh;
}

.control-group {
  margin-bottom: 25px;
}

.control-group label {
  padding-left: 48px;
  padding-top: 1px;
  position: relative;
  font-size: 22px;
}

.control-group label::before,
.control-group label::after {
  position: absolute;
}

.control-group label::before {
  border: 5px solid #5583f6;
  border-radius: 100%;
  box-sizing: border-box;
  content: "";
  display: block;
  height: 35px;
  width: 35px;
  top: -2px;
}

.control-group label::after {
  border: 6px solid #222;
  border-radius: 100%;
  box-sizing: border-box;
  content: "";
  display: block;
  height: 25px;
  width: 25px;
  top: 3px;
  left: 5px;
}

.control-group label.blue::after {
  background: #5583f6;
}

input[type=radio] {
  opacity: 0;
  position: absolute;
}

input[type=radio] + label::after {
  content: none;
}

input[type=radio]:checked + label::after {
  content: "";
}

input[type=radio]:checked + label.blue::before {
  border-color: #5583f6;
}

input[type=radio]:checked + label.jiggle::before {
  -webkit-animation-name: jiggle;
          animation-name: jiggle;
  -webkit-animation-duration: 700ms;
          animation-duration: 700ms;
  -webkit-animation-iteration-count: 1;
          animation-iteration-count: 1;
  -webkit-animation-timing-function: ease;
          animation-timing-function: ease;
  -webkit-animation-fill-mode: forwards;
          animation-fill-mode: forwards;
}

input[type=radio]:checked + label.jiggle::after {
  -webkit-animation-name: innerJiggle;
          animation-name: innerJiggle;
  -webkit-animation-duration: 700ms;
          animation-duration: 700ms;
  -webkit-animation-iteration-count: 1;
          animation-iteration-count: 1;
  -webkit-animation-timing-function: ease;
          animation-timing-function: ease;
  -webkit-animation-fill-mode: forwards;
          animation-fill-mode: forwards;
}

input[type=radio]:active + label::before {
  -webkit-animation-name: compress;
          animation-name: compress;
  -webkit-animation-duration: 700ms;
          animation-duration: 700ms;
  -webkit-animation-iteration-count: 1;
          animation-iteration-count: 1;
  -webkit-animation-timing-function: ease;
          animation-timing-function: ease;
  -webkit-animation-fill-mode: forwards;
          animation-fill-mode: forwards;
}

@-webkit-keyframes jiggle {
  0% {
    transform: scale(0.8, 0.8);
  }
  30% {
    transform: scale(0.75, 1.15);
  }
  50% {
    transform: scale(1.12, 0.75);
  }
  60% {
    transform: scale(0.9, 1.12);
  }
  70% {
    transform: scale(1.05, 0.95);
  }
  80% {
    transform: scale(0.85, 1.05);
  }
  90% {
    transform: scale(1.02, 0.98);
  }
  95% {
    transform: scale(0.98, 1.02);
  }
  98% {
    transform: scale(1.01, 0.99);
  }
  100% {
    transform: scale(1, 1);
  }.........完整代码请登录后点击上方下载按钮下载查看

网友评论0