svg+css实现橡胶弹性按钮点击效果代码

代码语言:html

所属分类:其他

代码描述:svg+css实现橡胶弹性按钮点击效果代码

代码标签: svg css 橡胶 弹性 按钮 点击

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

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

<head>
  <meta charset="UTF-8">
  

  <meta name="viewport" content="width=device-width, initial-scale=1">
  
  <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Rubik:wght@500&amp;display=swap'>
  
<style>
:root {
  --button-motion-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
  --button-motion-duration: 0s;
  --button-scale-up: 1.05;
  --button-scale-down: 0.95;
}

@media (prefers-reduced-motion: no-preference) {
  :root {
    --button-motion-duration: 0.3s;
  }
}

.button {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  line-height: 1;
  padding: 1em 1.5em;
  position: relative;
  transition: filter var(--button-motion-duration) var(--button-motion-ease);
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

.button:hover {
  filter: brightness(1.1);
}

.button:active {
  filter: brightness(0.9);
}

.button__content {
  display: block;
  position: relative;
  transition: transform var(--button-motion-duration) var(--button-motion-ease);
}

.button:hover .button__content {
  transform: scale(var(--button-scale-up));
}

.button:active .button__content {
  transform: scale(var(--button-scale-down));
}

.button__shape {
  fill: #950cde;
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  overflow: visible;
  transition: transform var(--button-motion-duration) var(--button-motion-ease);
}

@supports not (d: path('')) {
  .button:hover .button__shape {
    trans.........完整代码请登录后点击上方下载按钮下载查看

网友评论0