howler实现带刻度音效鸡蛋闹钟倒计时拖拽设置摇摆提醒代码

代码语言:html

所属分类:其他

代码描述:howler实现带刻度音效鸡蛋闹钟倒计时拖拽设置摇摆提醒代码,先拖拽刻度设置倒计时时间,然后闹钟就会倒计时,并发出秒针走动声音,一旦时间到了就会发出闹钟声音。

代码标签: howler 刻度 音效 鸡蛋 闹钟 倒计时 拖拽 设置 摇摆 提醒 代码

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

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

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

  
<style>
body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1em;
  min-height: 100vh;
  font-family: 'Helvetica', sans-serif;
  font-weight: 500;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
}

.egg-container {
  transform: scale(0.25);
  transition: transform .2s;
}
.egg-container.active {
  transform: scale(1);
}

.egg {
  --shadow-opacity: 1;
  border-radius: 100% 100% 76% 76% / 118% 118% 80% 80%;
  filter: drop-shadow(0 0px 2px Rgb(0 0 0/var(--shadow-opacity)));
  cursor: pointer;
}
.egg-container.active .egg {
  --shadow-opacity: 0;
  cursor: initial;
}
.egg.ringing {
  animation: ring .12s infinite;
}

@keyframes ring {
  0%,
  50%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(5deg);
  }
  75% {
    transform: rotate(-5deg);
  }
}
.egg-top {
  background-color: #f4f4f4;
  background-image: url("//repo.bfw.wiki/bfwrepo/icon/64dd70cc30755.png"), linear-gradient(to right, #e6e6e6, #ffffff, #e6e6e6);
  background-size: 60px 60px, auto auto;
  background-blend-mode: multiply, normal;
  --background-translation: 0px;
  position: relative;
  z-index: 1;
  border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
  width: 274px;
  height: 210px;
  clip-path: inset(0 0 0 0 round 50% 50% 50% 50%/100% 100% 0% 0%);
  background-position-x: var(--background-translation), 0%;
  box-shadow: inset 0 4px 8px Rgb(0 0 0/0.05), inset 20px 0 16px Rgb(0 0 0/0.05), inset -20px 0 16px Rgb(0 0 0/0.05), inset 0 1px 1px Rgb(0 0 0/0.05), inset 1px 0 1px Rgb(0 0 0/0.05), inset -1px 0 1px Rgb(0 0 0/0.05);
  transition: background-position-x .2s;
  touch-action: none;
}
.egg-top.dragged {
  transition-duration: 0s;
  transition-timing-function: ease-out;
}
.egg-container.active .egg:not(.ringing) .egg-top {
  cursor: ew-resize;
}

.time-ruler-faces-container {
  --initial-rotation: calc(180deg + (360deg / var(--face-count) / 2));
  --rotation: 0deg;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  bottom: 6px;
  transform: rotateY(calc(var(--rotation) + var(--initial-rotation)));
  transform-style: preserve-3d;
  aspect-ratio: 553.8592 / 76;
  width: 100%;
  transition: transform .4s;
}
.egg-top.dragged .time-ruler-faces-container {
  transition-duration: 0s;
  transition-timing-function: ease-out;
}

.time-ruler-face-wrapper {
  --angle: calc(360deg / var(--face-count) * var(--i));
  position: absolute;
  transform: rotateY(calc(var(--angle) - 90deg)) translateX(calc(100% / (2 * 0.06554) - 3px)) rotateY(90deg);
  backface-visibility: hidden;
  width: calc(100% * 0.0654);
  height: 100%;
  overflow: hidden;
}

.time-ruler-face {
  position: absolute;
  top: 0;
  left: calc(-100% * var(--i));
  height: 100%;
  fill: #484848;
  will-change: transform;
}

.egg-center {
  margin: 0 auto;
  height: 6px;
  width: calc(100% - 24px);
  background-color: #f4f4f4;
  box-shadow: inset 0 6px 2px Rgb(0 0 0/0.2), inset 0 2px 2px Rgb(0 0 0/0.2);
}

.egg-bottom {
  background-color: #f4f4f4;
  background-image: url("https://assets.codepen.io/4175254/final-2.png"), linear-gradient(to right, #e6e6e6, #ffffff, #e6e6e6);
  background-size: 60px 60px, auto auto;
  background-blend-mode: multiply, normal;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 0% 0% 38% 38% / 0% 0% 100% 100%;
  width: 274px;
  height: 144px;
  box-shadow: inset 0 1px 0 Rgb(255 255 255/0.8), inset 0 -1px 1px Rgb(0 0 0/0.05), inset 1px 0 1px Rgb(0 0 0/0.05), inset -1px 0 1px Rgb(0 0 0/0.05), inset 0 -12px 8px Rgb(255 255 255/0.6), inset 0 -20px 8px Rgb(0 0 0/0.1), inset 0 -60px 20px Rgb(0 0 0/0.05);
}

.time-arrow {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  margin-bottom: -1px;
  /*  border-bottom: $height solid #d15705;
    border-right: $width / 2 solid transparent;
    border-left: $width / 2 solid transparent;
    width: 0;
    height: 0;*/
  width: 20px;
  height: 14px;
  background-color: #d15705;
  clip-path: polygon(50% 0, 0% 100%, 100% 100%);
}

.time-container {
  border-radius: 10px;
  padding: 4px 16px;
  transform: scale(0.125, 0);
  transform-origin: top;
  background-color: #d15705;
  box-shadow: inset 0 -2px Rgb(0 0 0/0.2), 0 2px 4px Rgb(0 0 0/0.2);
  font-size: 32px;
  color: #f4f4f4;
  transition: transform .2s;
}
.egg-container.active .time-container {
  transform: scale(1);
  transition-duration: .2s;
  transition-timing-function: cubic-bezier(0, 0, 0.3, 1.5);
  transition-delay: .1s;
}

.timer-button {
  margin-top: 1.5em;
  border-radius: 8px;
  padding: 10px 16px;
  transform: scale(0);
  width: 100%;
  background-image: linear-gradient(to bottom, #84b709, #46a100);
  box-shadow: inset 0 -2px Rgb(0 0 0/0.2), 0 2px 4px Rgb(0 0 0/0.2);
  text-align: center;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  transition-property: transform, opacity;
  transition-duration: .4s, .2s;
  transition-timing-function: cubic-bezier(0.55, 1, 0.15, 1), ease-in-out;
}
.egg-container.active .timer-button {
  transform: scale(1);
  opacity: 1;
}
.timer-button.stop {
  background-image: linear-gradient(to bottom, #d53f0b, #b00000);
}
.timer-button:active:not(:disabled) {
  transform: scale(0.92);
}
.timer-button:disabled {
  background-image: linear-gradient(to bottom, #9f9f9f, #848484);
  cursor: not-allowed;
}
.egg-container.active .timer-button:disabled {
  opacity: .4;
}
</style>

  
  
  
</head>

<body >
  <div class="egg-container">
<div class="egg">
<div class="egg-top" style="--face-count: 48">
  <div class="time-ruler-faces-container">
    <div class="time-ruler-face-wrapper" style="--i: 0">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 1">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 2">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 3">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 4">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 5">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 6">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 7">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 8">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 9">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 10">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 11">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 12">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 13">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 14">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 15">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 16">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 17">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 18">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 19">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 20">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 21">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 22">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 23">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 24">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 25">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 26">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 27">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 28">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 29">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 30">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 31">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 32">
      <svg class="time-ruler-face" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1740 76" aria-hidden="true">
        <use href="#time-ruler"></use>
      </svg>
    </div>
    <div class="time-ruler-face-wrapper" style="--i: 33">
      <svg class="time.........完整代码请登录后点击上方下载按钮下载查看

网友评论0