js+svg实现图片删除液态消融消失动画效果代码

代码语言:html

所属分类:其他

代码描述:js+svg实现图片删除液态消融消失动画效果代码

代码标签: js svg 图片 删除 液态 消融 消失 动画

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

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

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

  
  
  
  
<style>
/* CSS */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: #000000;
  color: #ffffff;
  font-family: Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.image-container {
  position: relative;
  width: 500px;
  max-width: 90vw;
  height: 500px;
  margin-bottom: 20px;
  background-color: #000000;
  overflow: visible;
  border-radius: 24px;
}

#displayed-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: url(#dissolve-filter);
  transform: scale(1);
  opacity: 1;
  border-radius: 24px;
}

/* Delete button positioned above the image in the center */
#delete-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 24px;
  font-size: 16px;
  cursor: pointer;
  background-color: #650000;
  color: #FF5C5C;
  border: none;
  border-radius: 25px;
  transition: transform 0.2s ease;
  z-index: 1;
}

/* Hover state - same color but slightly bigger */
#delete-image:hover {
  transform: translate(-50%, -50%) scale(1.2);
}

/* Pressed state - scale down slightly */
#delete-image:active {
  transform: translate(-50%, -50%) scale(0.9);
}

.hidden {
  display: none;
}
</style>

  
  
</head>


  <body>
  <div class="container">
    <div class="image-container">
      <img id="displayed-image" src="https://i.ibb.co/2sxT6jZ/Retro-80s-Human-Flying-Poster-cropped.jpg" alt="Selected Image">
      <button id="delete-image">Delete Image</button>
    </div>
  </div>

  <!-- SVG Filter Definition -->
  <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
    <defs>
      <filter id="dissolve-filter" x="-200%" y="-200%" width="500%" height="500%" color-interpolation-filters="sRGB" overflow="visible">
        <feTurbulence type="fractalNoise" baseFrequency="0.004" numOctaves="1" result="bigNoise" />
        <feComponentTransfer in="bigNoise" result="bigNoiseAdjusted">
          <feFuncR type="linear" slope="3" intercept="-1" />
          <feFuncG type="linear" slope="3" intercept="-1" />
        </feComponentTransfer>
        <feTurbulence type="fractalNoise" baseFrequency="1" numOctaves="1" result="fineNoise" />

        
          <feBlend mode="overlay" in="bigNoiseAdjusted" in2="fineNoise" result="combinedNoise"/>

        <feDisplacementMap in="SourceGraphic" in2="combinedNoise" scale="0" xChannelSel.........完整代码请登录后点击上方下载按钮下载查看

网友评论0