|
|

楼主 |
发表于 2023-3-11 08:03
|
显示全部楼层
帖子代码
- <style>
- #papa {
- margin: -80px 0 0 calc(50% - 593px);
- width: 1024px;
- height: 640px;
- background: lightblue url('https://638183.freep.cn/638183/t23/1/destiny.jpg') center/cover no-repeat;
- box-shadow: 3px 3px 20px #000;
- position: relative;
- z-index: 1;
- }
- #mplayer {
- position: absolute;
- top: 22.7%; /*145px;*/
- left: 52.5%; /*538px;*/
- width: 80px;
- height: 80px;
- background: #E94142;
- transform: rotate(135deg);
- opacity: .8;
- filter: drop-shadow(260px -280px 20px #000);
- animation: beat .45s infinite alternate var(--state);
- cursor: pointer;
- --state: paused;
- }
- #mplayer::before, #mplayer::after {
- position: absolute;
- content: '';
- width: 100%;
- height: 100%;
- border-radius: 50%;
- background: inherit;
- }
- #mplayer::before { top: -50px; }
- #mplayer::after { left: 50px; }
- #mplayer:hover { background: red; }
- @keyframes beat { to { transform: rotate(135deg) scale(0.9); } }
- </style>
- <div id="papa">
- <div id="mplayer"></div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=541230" autoplay loop></audio>
- </div>
- <script>
- (function() {
- 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>
复制代码
|
|