|
|

楼主 |
发表于 2024-2-4 11:23
|
显示全部楼层
本帖最后由 马黑黑 于 2024-2-4 11:26 编辑
代码
- <style>
- #papa {
- margin: 0 0 0 calc(50% - 681px);
- width: 1200px;
- height: 675px;
- background:
- url('https://638183.freep.cn/638183/t24/jpg/dolan.jpg') no-repeat center/cover,
- url('https://638183.freep.cn/638183/small/dolan.png') repeat-x 0 100%;
- background-blend-mode: color-burn;
- box-shadow: 3px 3px 20px #000;
- position: relative;
- display: grid;
- place-items: center;
- z-index: 1;
- }
- #papa::after {
- position: absolute;
- content: '';
- inset: 0;
- background: rgba(0,0,0,.5);
- opacity: 0;
- pointer-events: none;
- animation: flash .1s infinite alternate var(--state);
- }
- .btnplay {
- position: absolute;
- cursor: pointer;
- animation: rot 5s linear infinite var(--state);
- }
- .btnplay:nth-of-type(2) {
- top: 2px;
- width: 120px;
- filter: invert(.8);
- animation-delay: -.6s;
- }
- @keyframes rot { to { transform: rotate(360deg); } }
- @keyframes flash { to { opacity: .5; } }
- </style>
- <div id="papa">
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1465729863" loop autoplay></audio>
- <img class="btnplay" src="https://638183.freep.cn/638183/small/4yc.png" alt="" title="播放/暂停" />
- <img class="btnplay" src="https://638183.freep.cn/638183/small/4yc.png" alt="" title="播放/暂停" />
- </div>
- <script>
- var btns = document.querySelectorAll('.btnplay');
- var mState = () => papa.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- aud.addEventListener('playing', mState, false);
- aud.addEventListener('pause', mState, false);
- btns.forEach(btn => btn.onclick = () => aud.paused ? aud.play() : aud.pause());
- </script>
复制代码
|
|