svg+css实现按钮点击激活动画效果代码

代码语言:html

所属分类:动画

代码描述:svg+css实现按钮点击激活动画效果代码

代码标签: svg css 按钮 点击 激活 动画

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


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

<head>

  <meta charset="UTF-8">

  <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Mukta+Malar:400,500,600'>
  
<style>
.activate {
  display: table;
  background: #5628EE;
  box-shadow: 0 4px 20px rgba(86, 40, 238, 0.15);
  line-height: 20px;
  padding: 12px;
  border-radius: 22px;
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.3s ease, box-shadow 0.3s ease;
}
.activate span {
  display: inline-block;
  vertical-align: top;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  margin: 0 4px 0 0;
  position: relative;
  overflow: hidden;
}
.activate span:before {
  content: "";
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  position: absolute;
  background: #5628EE;
  border-radius: 50%;
  transform: scale(0);
  transition: transform 0.3s ease, background 0.3s ease;
}
.activate span svg {
  position: absolute;
  width: 12px;
  height: 12px;
  left: 50%;
  top: 50%;
  margin: -6px 0 0 -6px;
  z-index: 1;
}
.activate span svg:nth-child(1) {
  width: 20px;
  height: 20px;
  top: 0;
  left: 0;
  fill: none;
  margin: 0;
  stroke: #fff;
  stroke-width: 1px;
  stroke-dashoffset: 94.248;
  stroke-dasharray: 47.124;
}
.activate span svg:nth-child(2) {
  fill: #5628EE;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.activate span svg:nth-child(3) {
  fill: #5628EE;
  transform: translateY(20px);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}
.activate:hover {
  box-shadow: 0 8px 24px rgba(86, 40, 238, 0.15);
}
.activate:hover span svg:nth-child(2) {
  transform: translateY(-20px);
}
.activate:hover span svg:nth-child(3) {
  transform: translateY(0);
}
.activate:active {
  transform: scale(0.94);
  box-shadow: 0 4px 16px rgba(63, 220, 117, 0.18);
}
.activate.loading span {
  background: none;
  transition: background 0.1s ease 0.3s;
}
.activate.loading span:before {
  transform: scale(1);
}
.activate.loading span svg:nth-child(1) {
  -webkit-animation: turn 1.6s linear infinite forwards, path 1.6s linear infinite forwards;
          animation: turn 1.6s linear infinite forwards, path 1.6s linear infinite forwards;
}
.activate.loading span svg:nth-child(2) {
  transform: translateY(-20px);
}
.activate.loading span svg:nth-child(3) {
  opacity: 0;
  transform: translateY(0) scale(0.6);
}
.activate.loading ul {
  transform: rotateX(90deg);
}
.activate.loading.done {
  background: #3FDC75;
  box-shadow: 0 4px 20px rgba(63, 220, 117, 0.15);
}
.activate.loading.done span {
  background: #fff;
  transition: background 0.1s ease 0s;
}
.activate.loading.done span:before {
  background: #3FDC75;
  transform: scale(0);
}
.activate.loading.done span svg:nth-child(1) {
  -webkit-animation: none;
          animation: none;
}
.activate.loading.done span svg:nth-child(3) {
  fill: #3FDC75;
  opacity: 1;
  transform: scale(1);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.3s, opacity 0.4s ease 0.25s;
}
.activate.loading.done ul {
  transform: rotateX(180deg);
}
.activate ul {
  padding: 0;
  margin: 0;
  list-style: none;
  height: 20px;
  width: 70px;
  display: inline-block;
  vertical-align: top;
  text-align: center;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}
.activate ul li {
  --rotateX: 0deg;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  transform-origin: 50% 50%;
  transform: rotateX(var(--rotateX)) translateZ(10px);
}
.activate ul li:nth-child(2) {
  --rotateX: -90deg;
}
.activate ul li:nth-child(3) {
  --rotateX: -180deg;
}

@-webkit-keyframes turn {
  100% {
    transform: .........完整代码请登录后点击上方下载按钮下载查看

网友评论0