svg实现一个液体按钮效果代码

代码语言:html

所属分类:表单美化

代码描述:svg实现一个液体按钮效果代码,鼠标放上去试试

代码标签: 液体 按钮 效果

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

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

<head>

  <meta charset="UTF-8">
  

  
  
<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  position: relative;
  display: grid;
  height: 100vh;
  place-items: center;
  background: #ede9fe;
  overflow: hidden;
  color: #4c1d95;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

svg {
  overflow: visible;
}

.wobble {
  position: relative;
  width: 256px;
  height: 56px;
  background: none;
  border: none;
  color: #f5f3ff;
  cursor: pointer;
  font-family: "Nunito", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  overflow: visible;
  outline: none;
}

.wobble svg {
  /*   filter: drop-shadow(0px 8px 16px rgba(139, 92, 246, 0.75)); */
  overflow: visible;
}

.wobble #btnPath {
  stroke: transparent;
  stroke-width: 3;
}

.wobble > * {
  pointer-events: none !important;
}

.wobble:focus #btnPath {
  stroke-width: 3;
  stroke: #fcd34d;
}

.wobble svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

.toggle-points {
}

.blob {
  position: absolute;
  bottom: -25%;
  right: -25%;
  width: 50vw;
}

.blob path {
  fill: #ddd6fe;
}

.blob:nth-of-type(2) {
  top: -25%;
  left: -25%;
  bottom: auto;
  right: auto;
}

.debug-text {
  font-family: "Nunito", sans-serif;
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  cursor: pointer;
}

.debug-dot {
  opacity: 0;
}

.debug .debug-dot {
  opacity: 1 !important;
}
</style>


</head>

<body  >
  <button class="wobble">
  Liquid SVG Button 💛
  <svg width="256" height="56" viewBox="0 0 256 56" fill="none" xmlns="http://www.w3.org/2000/svg">
    <defs>
      <linearGradient id="gradient" gradientTransform="rotate(90)">
        <stop offset="5%" stop-color="#7C3AED" />
        <stop offset="95%" stop-color="#8B5CF6" />
      </linearGradient>
      <filter id="shadow" filterUnits="userSpaceOnUse" height="200" width="512" y="0">
        <feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#7C3AED" flood-opacity="0.3" />
      </filter>
    </defs>
    <path id="baseBtnPath" d="M0 28C0 12.536 12.536 0 28 0H228C243.464 0 256 12.536 256 28C25.........完整代码请登录后点击上方下载按钮下载查看

网友评论0