|
|

楼主 |
发表于 2022-5-22 08:37
|
显示全部楼层
代码分享:
- <style>
- .bgbox {
- left: -281.5px;
- width: 1159px;
- height: 799px;
- background-color: tan;
- background-image: url('/data/attachment/forum/202205/22/082641jj8pzhzsacda0mbx.jpg'),
- url('/data/attachment/forum/202205/22/082641b8izdmv3t7mmhvl3.png');
- background-repeat: no-repeat;
- background-position: center, right bottom;
- background-blend-mode: soft-light, screen;
- box-shadow: 2px 2px 6px gray;
- position: relative;
- }
- .tube {
- display: flex;
- justify-content: center;
- width: 10px;
- height: 100px;
- background-color: #eee;
- background: linear-gradient(#aaa 1px, #eee 1px);
- background-size: 8px 10px;
- box-shadow: 0 -8px 0 0 red, 0 18px 0 0 red;
- border-radius: 4px;
- overflow: hidden;
- cursor: pointer;
- transform: translate(10px, 669px);
- position: relative;
- }
- .ball {
- position: absolute;
- width: 4px;
- height: 100px;
- background: rgba(255,0,0,.45);
- top: 100px;
- }
- </style>
- <div class="bgbox">
- <div class="tube">
- <div class="ball"></div>
- </div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1305764737.mp3" loop="loop" autoplay="autoplay"></audio>
- </div>
- <script>
- let aud = document.querySelector('#aud');
- let tube = document.querySelector('.tube');
- let ball = document.querySelector('.ball');
- let task, current;
- aud.addEventListener('timeupdate', function(){
- task = aud.duration;
- current = aud.currentTime;
- setProgress(task,current);
- });
- tube.onclick = () =>{ aud.paused ? aud.play() : aud.pause(); };
- function setProgress(tt,cc) {
- if(tt <= 0 || cc <= 0) return false;
- let prog = 100 * cc / tt;
- ball.style.transform = 'translateY(-' + prog + 'px)';
- }
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|