|
|

楼主 |
发表于 2023-2-16 21:48
|
显示全部楼层
代码很少
- <style>
- #papa {
- margin: -80px 0 0 calc(50% - 593px);
- width: 1024px;
- height: 640px;
- background: darkblue url('https://638183.freep.cn/638183/t23/1/siji.jpg') no-repeat center/cover;
- box-shadow: 3px 3px 20px #000;
- position: relative;
- z-index: 1;
- }
- #mplayer {
- --state: paused;
- --angle: 360deg;
- position: absolute;
- left: 62%;
- top: 16%;
- width: fit-content;
- height: fit-content;
- padding: 4px;
- border: 4px dotted pink;
- border-radius: 50%;
- cursor: pointer;
- animation: rot infinite 10s linear var(--state);
- }
- #mplayer::before, #mplayer::after {
- position: absolute;
- content: '';
- top: -10px; left: -10px; bottom: -10px; right: -10px;
- border: 4px dotted purple;
- border-radius: 50%;
- animation: rot infinite 5s linear;
- animation-play-state: var(--state);
- --angle: -360deg;
- }
- #mplayer::after {
- top: -16px; left: -16px; bottom: -16px; right: -16px;
- border-color: darkred;
- animation-duration: 12s;
- --angle: 360deg;
- }
- #mplayer > img { width: 160px; height: 160px; border-radius: 50%; }
- @keyframes rot {
- from { transform: rotate(0); }
- to { transform: rotate(var(--angle)); }
- }
- </style>
- <div id="papa">
- <div id="mplayer"><img src="https://638183.freep.cn/638183/t23/webp/siji.webp" alt="" /></div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1393676639.mp3" loop autoplay></audio>
- </div>
- <script>
- let mState = () => mplayer.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- aud.addEventListener('play', () => mState());
- aud.addEventListener('pause', () => mState());
- mplayer.addEventListener('click', () => aud.paused ? aud.play() : aud.pause());
- </script>
复制代码
|
|