|
|

楼主 |
发表于 2024-1-12 08:58
|
显示全部楼层
代码
- <style>
- #papa {
- margin: 0 0 0 calc(50% - 801px);
- width: 1440px;
- height: 810px;
- background: url('https://638183.freep.cn/638183/t24/jpg/dream.jpg') no-repeat center/cover;
- box-shadow: 4px 4px 16px rgba(0,0,0,.7);
- overflow: hidden;
- position: relative;
- pointer-events: none;
- }
- #papa::before, #papa::after {
- position: absolute;
- content: '';
- width: 100%;
- height: 100%;
- }
- #papa::after {
- background: rgba(0,122,45,.5);
- clip-path: polygon(50% 0,100% 50%,50% 100%, 0 50%);
- animation: opt 20s infinite alternate var(--state);
- }
- #papa::before {
- width: 428px;
- height: 428px;
- left: calc(50% - 214px);
- top: calc(50% - 214px);
- clip-path: circle(214px);
- background: url('https://638183.freep.cn/638183/t24/webp/dreamgirl.webp') no-repeat center;
- opacity: .45;
- box-shadow: inset 0 0 300px blue;
- cursor: pointer;
- pointer-events: auto;
- animation: rot 10s infinite linear var(--state);
- }
- @keyframes opt {
- from { transform: scale(1) rotate(0); }
- to { transform: scale(0) rotate(45deg); }
- }
- @keyframes rot { to { transform: rotate(360deg); } }
- </style>
- <div id="papa" title="play|pause"></div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1494213335" autoplay loop></audio>
- <script>
- var mState = () => aud.paused ?
- (papa.style.setProperty('--state','paused'),papa.title = '点击播放') :
- (papa.style.setProperty('--state','running'),papa.title = '点击暂停');
- aud.addEventListener('playing', mState, false);
- aud.addEventListener('pause', mState, false);
- papa.addEventListener('click', () => aud.paused ? aud.play() : aud.pause());
- </script>
复制代码
|
|