|
|

楼主 |
发表于 2023-8-14 08:17
|
显示全部楼层
本帖最后由 马黑黑 于 2023-8-14 12:00 编辑
简单模拟,没有追求逼真外观效果。网上这类作品有很逼真的,有兴趣的朋友可以去搜搜。本帖代码原创,代码如下:- <style>
- #mplayer {
- margin: 20px auto;
- width: 200px;
- height: 120px;
- background: linear-gradient(tan,navy,transparent);
- box-shadow: 0 0 8px #666, 0 0 50px #999 inset, 0 0 20px #666;
- color: antiquewhite;
- display: grid;
- place-items: center;
- position: relative;
- --prg: 25%; --state: paused;
- }
- #mplayer > span { position: absolute; }
- #mplayer::before, #mplayer::after {
- position: absolute;
- content: '';
- }
- #mplayer::before {
- left: 6px;
- top: 6px;
- width: 10px;
- height: 10px;
- border-radius: 50%;
- background: gray;
- box-shadow: 178px 0 0 gray, 0 98px 0 0 gray, 178px 98px 0 0 gray;
- }
- /*
- #mplayer::after {
- width: 78px;
- height: 24px;
- border-radius: 24px;
- background: lightgray;
- }
- */
- #btnP1, #btnP2 {
- width: 50px;
- height: 50px;
- border-radius: 50%;
- border: 1px solid silver;
- display: grid;
- place-items: center;
- cursor: pointer;
- animation: rot 5s infinite linear var(--state);
- }
- #btnP1 {
- left: 20px;
- background: gray radial-gradient(
- transparent,
- transparent 20%,
- #000 calc(20% + 1px),
- #000 calc(100% - var(--prg)),
- transparent calc(100% - var(--prg) + 1px),
- transparent 0
- );
- }
- #btnP2 {
- right: 20px;
- background: gray radial-gradient(
- transparent,
- transparent 20%,
- #000 calc(20% + 1px),
- #000 var(--prg),
- transparent calc(var(--prg) + 1px),
- transparent 0
- );
- }
- #btnP1::after, #btnP2::after {
- position: absolute;
- content: '';
- width: 18px;
- height: 18px;
- border-radius: 50%;
- border: 2px dotted rgba(250,250,250,.7);
- }
- #titP { top: 10px; font-size: 12px; }
- @keyframes rot { to { transform: rotate(1turn); } }
- </style>
- <div id="mplayer">
- <span id="titP">HCPlayer</span>
- <span id="btnP1"></span>
- <span id="btnP2"></span>
- </div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1488294593" loop autoplay></audio>
- <script>
- let mState = () => mplayer.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- aud.addEventListener('play', mState, false);
- aud.addEventListener('pause', mState, false);
- aud.addEventListener('timeupdate', () => {
- let prg = aud.currentTime / aud.duration * 100 + 20;
- mplayer.style.setProperty('--prg', prg + '%');
- });
- btnP1.onclick = btnP2.onclick = () => aud.paused ? aud.play() : aud.pause();
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|