|
|

楼主 |
发表于 2023-5-20 12:12
|
显示全部楼层
本帖最后由 马黑黑 于 2023-5-20 12:13 编辑
帖子代码
- <css-doodle grid="5" id="mplayer">
- :doodle {
- @size: 1024px 640px;
- background: url('https://638183.freep.cn/638183/t23/webp1/sea1.webp') no-repeat center/cover, linear-gradient(blue,green);
- background-blend-mode: lighten;
- box-shadow: 0 0 8px #000;
- position: relative;
- margin: -80px 0 0 calc(50% - 593px);
- z-index: 1;
- --state: paused;
- }
- @match(@i ≤ @size - 1) {
- @size: @r(50,100)px;
- @shape: @p(fish, whale);
- @place:50px 50px;
- background: rgba(@m3(@r(255)), .9);
- offset-path: path('M@r(200) @r(200), L@r(800,1000) @r(300), L@r(400,550) @r(500,640)Z');
- :after {
- position:absolute;
- content: '';
- right: 10px;
- width: 10px;
- height: 10px;
- border-radius: 50%;
- background: radial-gradient(black,snow);
- }
- animation: swim @r(10,30)s @r(-10, 0)s infinite ease-in-out var(--state);
- }
- @nth(@size) {
- @shape: bud 5;
- @size: 100px;
- @place: center 90%;
- background: rgba(200,20,20,.65);
- cursor: pointer;
- animation: rot 5s infinite linear var(--state);
- }
- @keyframes swim { to { offset-distance: 100%; } }
- @keyframes rot { to { transform: rotate(360deg); } }
- </css-doodle>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1859139069" autoplay="autoplay" loop="loop"></audio>
- <script>
- (function() {
- let script = document.createElement('script');
- script.src = '/css-doodle.min.js';
- document.head.appendChild(script);
- let mState = () => mplayer.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- aud.addEventListener('play', mState, false);
- aud.addEventListener('pause', mState, false);
- mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();
- })();
- </script>
复制代码
|
|