Skip to content
索引

圆形水波纹

vue
<template>
  <view class="ripple-container">
    <button class="ripple-button">Click me!</button>
  </view>
</template>

<style>
.ripple-container {
  position: relative;
  width: fit-content;
}
.ripple-button {
  background-color: #007bff;
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background-color 0.3s ease-out;
}
.ripple-button:hover {
  background-color: #0056b3;
}
.ripple-button::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 1s;
}
.ripple-button:active::before {
  transform: scale(0, 0);
  opacity: 0.5;
  transition: 0s;
}
</style>
<template>
  <view class="ripple-container">
    <button class="ripple-button">Click me!</button>
  </view>
</template>

<style>
.ripple-container {
  position: relative;
  width: fit-content;
}
.ripple-button {
  background-color: #007bff;
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background-color 0.3s ease-out;
}
.ripple-button:hover {
  background-color: #0056b3;
}
.ripple-button::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 1s;
}
.ripple-button:active::before {
  transform: scale(0, 0);
  opacity: 0.5;
  transition: 0s;
}
</style>

Released under the MIT License.