gsap+svg实现按钮下单点击拖动确认效果代码

代码语言:html

所属分类:表单美化

代码描述:gsap+svg实现按钮下单点击拖动确认效果代码

代码标签: 下单 点击 拖动 确认 效果

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


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

<head>

  <meta charset="UTF-8">

  <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Inter:400,500,600,700&amp;display=swap'>
  
<style>
.button {
  --text: #FFFFFF;
  --background: #275EFE;
  --background-opacity: 1;
  --handle-stroke: rgba(255, 255, 255, 0.8);
  --handle-fill: rgba(255, 255, 255, 0.08);
  --handle-blur: 2;
  --drop-stroke: rgba(255, 255, 255, 0.2);
  --drop-fill: rgba(255, 255, 255, 0);
  --icon-stroke: #FFFFFF;
  --icon-rotate: 0;
  --icon-scale: 1;
  --icon-y: 0;
  --icon-offset: 16.8;
  --handle-drop-opacity: 0;
  --default-opacity: 1;
  --default-x: 0;
  --default-scale: 1;
  --progress-opacity: 0;
  --progress-scale: .75;
  --success-opacity: 0;
  --success-x: 0;
  --success-scale: .75;
  display: block;
  cursor: pointer;
  position: relative;
  text-align: center;
  outline: none;
  border: none;
  overflow: hidden;
  padding: 8px 0;
  margin: 0;
  width: 148px;
  line-height: 30px;
  font-family: inherit;
  font-weight: 600;
  border-radius: 16px;
  color: var(--text);
  background: var(--background);
  transform: scale(var(--button-scale, 1)) translateZ(0);
  transition: transform 0.15s;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.button .handle,
.button .progress,
.button .success,
.button .drop {
  position: absolute;
  left: var(--left, auto);
  right: var(--right, auto);
  top: var(--top, auto);
}
.button .handle {
  -webkit-backdrop-filter: blur(calc(var(--handle-blur) * 1px));
  backdrop-filter: blur(calc(var(--handle-blur) * 1px));
}
.button .handle,
.button .drop {
  --top: 8px;
  z-index: 1;
  border-radius: 11px;
  opacity: var(--handle-drop-opacity);
  pointer-events: var(--handle-drop-pointer, auto);
}
.button .handle svg,
.button .drop svg {
  display: block;
  width: var(--svg-size, 40px);
  height: var(--svg-size, 40px);
  stroke-width: 1px;
  stroke: var(--stroke, var(--handle-stroke));
  fill: var(--fill, var(--handle-fill));
}
.button .handle svg.background,
.button .drop svg.background {
  margin: -5px;
  opacity: var(--background-opacity);
}
.button .handle svg.icon,
.button .drop svg.icon {
  --svg-size: 20px;
  --fill: none;
  --stroke: var(--icon-stroke);
  position: absolute;
  left: 5px;
  top: 5px;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 8.5;
  stroke-dashoffset: var(--icon-offset);
  transform: translateY(calc(var(--icon-y) * 1px)) rotate(calc(var(--icon-rotate) * 1deg)) scale(var(--icon-scale)) translateZ(0);
}
.button .handle {
  --left: 8px;
}
.button .drop {
  --right: 8px;
  --stroke: var(--drop-stroke);
  --fill: var(--drop-fill);
}
.button .default,
.button .progress,
.button .success {
  display: block;
  font-size: var(--font-size, 14px);
  opacity: var(--opacity, var(--default-opacity));
  transform: translateX(calc(var(--x, var(--default-x)) * 1px)) scale(var(--scale, var(--default-scale))) translateZ(0);
}
.button .progress,
.button .success {
  --left: 0;
  --right: 0;
  --top: 8px;
}
.button .progress {
  --font-size: 11px;
  --opacity: var(--progress-opacity);
  --scale: var(--progress-scale);
}
.button .success {
  --font-size: 14px;
  --opacity: var(--success-opacity);
  --x: var(--success-x);
  --scale: var(--success-scale);
}
.button:not(.active) {
  --handle-drop-pointer: none;
}
.button:not(.active):active {
  --button-scale: .975;
}

html {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: inherit;
}
*:before, *:after {
  box-sizing: inherit;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: "Inter", Arial;
  background: #E1E6F9;
}
body .dribbble {
  position: fixed;
  display: block;
  right: 20px;
  bottom: 20px;
}
body .dribbble img {
  display: block;
  height: 28px;
}
body .twitter {
  position: fixed;
  display: block;
  right: 64px;
  bottom: 14px;
}
body .twitter svg {
  width: 32px;
  height: 32px;
  fill: #1da1f2;
}
</style>


</head>

<body >
  <button class="button">
    <span class="handle">
        <svg class="background" viewBox="0 0 40 40">
            <path d="M5 16C5 9.92487 9.92487 5 16 5H24C30.0751 5 35 9.92487 35 16C35 16 35 18.4379 35 20C35 21.5621 35 24 35 24C35 30.0751 30.0751 35 24 35H16C9.92487 35 5 30.0751 5 24C5 24 5 21.5621 5 20C5 18.4379 5 16 5 16Z"></path>
        </svg>
        <svg class="icon" viewBox="0 0 20 20">
            <polyline points="9 13 12 10 8 6"></polyline>
        </svg>
    </span>
    <span class="default">Buy now</span>
    <span class="progress">Confirm</span>
    <span class="success">Done</span>
    <span class="drop">
        <svg class="background" viewBox="0 0 40 40">
            <path d="M5 16C5 9.92487 9.92487 5 16 5H24C30.0751 5 35 9.92487 35 16C35 16 35 18.4379 35 20C35 21.5621 35.........完整代码请登录后点击上方下载按钮下载查看

网友评论0