|
|

楼主 |
发表于 2022-5-23 12:21
|
显示全部楼层
- <style>
- .wrapper {
- left: 100px;
- top: 100px;
- width: 30px;
- height: 200px;
- position: relative;
- cursor: pointer;
- }
- .candle {
- position: absolute;
- width: inherit;
- height: inherit;
- box-shadow: inset 0 0 1px 0 rgba(0,0,0,.35), 1px 1px 30px gray;
- background: linear-gradient(to right,#eee 1%,snow,#eee 99%);
- bottom: 0;
- }
- .candle::before ,.candle::after { position: absolute; content: ''; }
- .candle::before {
- width: 40px;
- height: 40px;
- border-radius: 0 80%;
- background: linear-gradient(to left bottom, red 30%, #fff, red 70%);
- box-shadow: inset 2px 2px 4px yellow, inset 2px 2px 4px gold;
- top: -45px;
- left: -3px;
- transform: rotate(45deg);
- filter: blur(1px);
- animation: burn .5s ease-in-out infinite alternate;
- }
- .candle::after {
- width: 100%;
- height: 15px;
- background: inherit;
- }
- @keyframes burn { to { height: 50px; } }
- </style>
- <div class="wrapper">
- <div class="candle"></div>
- </div>
- <audio id="myaud" src="http://www.kumeiwp.com/sub/filestores/2022/05/14/def3513e7e61d2a3a6a946ef2906fc27.mp3" autoplay="autoplay" loop="loop"></audio>
- <script>
- let controler = document.querySelector('.candle');
- let aud = document.querySelector('#myaud');
- let task = aud.duration, current;
- controler.onclick = () =>{
- aud.paused ? aud.play() : aud.pause();
- }
- aud.addEventListener('timeupdate', function(){
- task = aud.duration;
- current = aud.currentTime;
- setProgress(task,current);
- });
- function setProgress(tt,cc) {
- if(tt <= 0 || cc <= 0) return false;
- let prog = 100 - 100 * cc / tt;
- controler.style.height = prog + '%';
- }
- </script>
复制代码
|
|