js+svg实现按钮点击不松手发布进度动画效果代码

代码语言:html

所属分类:表单美化

代码描述:js+svg实现按钮点击不松手发布进度动画效果代码

代码标签: js svg 按钮 点击 不松手 发布 进度 动画

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


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

<head>

  <meta charset="UTF-8">


  <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto:400,500,700&amp;display=swap'>
  
<style>
.button-hold {
  --color: #F6F8FF;
  --background: #2B3044;
  --icon: var(--color);
  --progress-border: #646B8C;
  --progress-active: #fff;
  --progress-success: #5C86FF;
  --tick-stroke: var(--progress-active);
  --shadow: rgba(0, 9, 61, 0.2);
  font-size: 16px;
  font-weight: 500;
  line-height: 19px;
  min-width: 112px;
  padding: 12px 20px 12px 12px;
  border: 0;
  border-radius: 24px;
  outline: none;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  cursor: pointer;
  -webkit-backface-visibility: hidden;
  -webkit-appearance: none;
  transition: transform 0.3s, box-shadow 0.3s;
  box-shadow: 0 var(--shadow-y, 4px) var(--shadow-blur, 12px) var(--shadow);
  transform: scale(var(--scale, 1)) translateZ(0);
  color: var(--color);
  background: var(--background);
}
.button-hold > div {
  margin-right: 4px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: top;
  position: relative;
  background: var(--progress-border);
}
.button-hold > div:before {
  content: "";
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  z-index: 1;
  position: absolute;
  background: var(--background);
  border-radius: inherit;
  transform: scale(var(--background-scale, 1));
  transition: transform 0.32s ease;
}
.button-hold > div svg {
  display: block;
}
.button-hold > div svg.icon, .button-hold > div svg.tick {
  position: absolute;
}
.button-hold > div svg.icon {
  width: 8px;
  height: 8px;
  left: 6px;
  top: 6px;
  fill: var(--icon);
  z-index: 1;
  transition: opacity 0.2s, transform 0.2s;
  opacity: var(--icon-opacity, 1);
  transform: translateY(var(--icon-y, 0)) scale(var(--icon-scale, 1));
}
.button-hold > div svg.progress, .button-hold > div svg.tick {
  fill: none;
}
.button-hold > div svg.progress {
  width: 20px;
  height: 20px;
  transform: rotate(-90deg) scale(var(--progress-scale, 1));
  transition: transform 0.5s ease;
}
.button-hold > div svg.progress circle {
  stroke-dashoffset: 1;
  stroke-dasharray: var(--progress-array, 0) 52;
  stroke-width: 16;
  stroke: var(--progress-active);
  transition: stroke-dasharray var(--duration) linear;
}
.button-hold > div svg.tick {
  width: 20px;
  height: 20px;
  left: 0;
  top: 0;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke: var(--tick-stroke);
  transition: stroke 0.3s ease 0.7s;
}
.button-hold > div svg.tick polyline {
  stroke-dasharray: 18 18 18;
  stroke-dashoffset: var(--tick-offset, 18);
  transition: stroke-dashoffset 0.4s ease 0.7s;
}
.button-hold:focus:not(.process), .button-hold:hover:not(.process) {
  --shadow-y: 8px;
  --shadow-blur: 16px;
}
.button-hold:active:not(.success) {
  --scale: .96;
  --shadow-y: 4px;
  --shadow-blur: 8px;
}
.button-hold.process, .button-hold.success {
  --progress-array: 52;.........完整代码请登录后点击上方下载按钮下载查看

网友评论0