css+div实现播放按钮变身录音机动画效果代码

代码语言:html

所属分类:动画

代码描述:css+div实现播放按钮变身录音机动画效果代码

代码标签: css div 播放 按钮 变身 录音机 动画

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

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

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

  
  
<style>
body {
  background: #fff;
  height: 100vh;
  width: 100vw;
  display: grid;
  place-items: center;
  overflow: hidden;
}

#button-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: 1fr;
  grid-column-gap: 20px;
}
#button-row > div {
  transition: 0.3s ease-in-out;
  z-index: 1;
}
#button-row > div:last-of-type {
  z-index: 0;
}
#button-row > div:after {
  content: "";
  position: absolute;
  width: 100px;
  height: 100px;
  top: calc(50% - 50px);
  left: calc(50% - 50px);
  background: transparent;
  box-shadow: 0 0 0 1px #ccc, 0 20px 40px -15px rgba(0, 0, 0, 0.25);
  z-index: 9;
  pointer-events: none;
  transition: 0.3s ease-in-out;
}
#button-row:has(button.playing) > div:after {
  box-shadow: 0 0 0 0px #ccc, 0 20px 40px -95px rgba(0, 0, 0, 0.25);
  transform: scale(2);
}
#button-row:has(#button-container-1 button.playing) #button-container-2 {
  transform: scale(0);
}
#button-row:has(#button-container-1 button:hover) #button-container-2:after {
  box-shadow: 0 0 0 0px #ccc, 0 20px 40px -95px rgba(0, 0, 0, 0.25);
}
#button-row:has(#button-container-2 button.playing) #button-container-1 {
  transform: scale(0);
}
#button-row:has(#button-container-2 button:hover) #button-container-1:after {
  box-shadow: 0 0 0 0px #ccc, 0 20px 40px -95px rgba(0, 0, 0, 0.25);
}

#button-container-1 {
  display: flex;
  justify-content: center;
  align-items: center;
  height: auto;
  width: auto;
  position: relative;
}
#button-container-1 > div {
  width: 50px;
  height: 50px;
  background: #000;
  position: relative;
  cursor: pointer;
  border-radius: 100px;
  transition: border-radius 0.75s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.25s, box-shadow 0.35s ease-in-out 0s;
  box-shadow: inset 0 0 0 0px #000, inset 0 0 0 -2px #fff;
  overflow: hidden;
}
#button-container-1 > div:before, #button-container-1 > div:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  z-index: 9;
  transition: opacity 0.3s ease-in-out;
  background: conic-gradient(#5454bb 0%, #b757aa 11%, #e76e91 21%, #fc9783 31%, #fdc48b 41%, #f7f1b1 51%, #ffeab8 61%, #ffe1bd 71%, #ffdcc7 80%, #b757aa 90%, #5454bb 100%);
  mix-blend-mode: darken;
  border-radius: inherit;
  pointer-events: none;
  -webkit-mask: radial-gradient(circle at center, transparent 50%, #000 25%);
  opacity: 0.75;
  animation: spin 2s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
#button-container-1 > div:after {
  opacity: 0;
  width: 150%;
  height: 150%;
  left: -25%;
  top: -25%;
  -webkit-mask: radial-gradient(circle at center, transparent 25%, #000 25%);
}
#button-container-1 > div > div {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0