|
|
思路是对的,一些细节需要处理。代码加工如下:
- <style>
- #papa {
- margin: 80px 0 0 calc(50% - 681px);
- width: 1200px;
- height: 700px;
- background: tan;
- box-shadow: 0 0 10px gray;
- position: relative;
- --state: paused;
- }
- css-doodle { position: absolute; }
- .vid { position: absolute; width: 1200px; height: 700px; object-fit: cover; opacity: 1; }
- </style>
- <div id="papa">
- <video class="vid" src="https://img-baofun.zhhainiao.com/pcwallpaper_ugc/preview/15ffded0ce14cc4ed9cff128e93adcf7_preview.mp4" autoplay="autoplay" loop="loop" muted="muted"></video>
- <css-doodle grid="5" id="mplayer">
- :doodle {
- @size: 1200px 700px;
- z-index: 1;
- }
- @match(@i ≤ @size - 1) {
- @size: @r(40,110)px;
- position: absolute;
- @shape: @p(fish, whale);
- @place:50px 50px;
- background: SlateBlue;
- offset-path: path('M@r(200) @r(200,400), L@r(500,700) @r(300), L@r(1000,1160) @r(200,400), L@r(400,550) @r(300,460)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) {
- @size: 120px;
- @place: center 78%;
- background: rgba(0,255,0,.75);
- cursor: pointer;
- clip-path: @shape(
- points: 300;
- scale: .7;
- r: cos.cos.cos.cos.cos(7t) ^ cos(7t);
- );
- animation: rot 5s infinite linear var(--state);
- }
- @keyframes swim { to { offset-distance: 100%; } }
- @keyframes rot { to { transform: rotate(360deg); } }
- </css-doodle>
- <css-doodle id="lrc">
- :doodle {
- @size: auto 4em;
- left: 10px;
- bottom: 10px;
- --geci: "css-doodle player"; --motion: cover2; --tt: 1s;
- }
- /* 单元格两个伪元素显示lrc歌词 */
- display: grid;
- place-items: center start;
- :before, :after {
- content: var(--geci);
- color: gray; /* 歌词底色 */
- font: bold 2em sans-serif;
- text-shadow: 1px 1px 2px #000;
- white-space: pre;
- }
- :after {
- position: absolute;
- width: 0;
- color: darkgreen; /* 同步歌词颜色 */
- overflow: hidden;
- animation: var(--motion) var(--tt) linear forwards var(--state);
- }
- @keyframes cover1 { from { width: 0; } to { width: 100%; } }
- @keyframes cover2 { from { width: 0; } to { width: 100%; } }
- </css-doodle>
- <audio id="aud" src="https://www.qqmc.com/mp3/music277192354.mp3" autoplay loop></audio>
- </div>
- <script>
- (function() {
- let script = document.createElement('script');
- script.src = 'https://unpkg.com/css-doodle@0.34.9/css-doodle.min.js';
- document.head.appendChild(script);
- let slip = 0.5, mFlag = true, mKey = 0, clickIdx = 0, progChg = 0, cursors = ['default','pointer','pointer'];
- let lrcAr = [
- [0,"黄静美 - 如果你一贫如洗",0.0],
- [0.01,"作词:冯海毓",0.1],
- [0.1,"作曲:小米",2.9],
- [3.03,"编曲:江历",1.0],
- [4.04,"吉他:陈宁",1.0],
- [5.06,"和声编写、和声:谌宥",1.0],
- [6.07,"人声编辑:迟色",1.0],
- [7.08,"混音师:浓汤宝",1.0],
- [8.09,"统筹:小法",1.9],
- [10,"制作人:何文宇",1.0],
- [11.01,"策划: 陈玉荣",1.0],
- [12.02,"宣发:星云计划",1.0],
- [13.04,"监制:熊磊、王腾飞",1.0],
- [14.05,"发行人:韦琪",1.0],
- [15.06,"发行公司:万象星云",1.0],
- [16.07,"LRC编辑:醉美水芙蓉",1.0],
- [17.08,"人生啊仔细想想",3.0],
- [20.09,"没有太多 眷恋的东西",4.0],
- [24.05,"唯有身边的你",3.0],
- [27.01,"是我一生的惦记",5.0],
- [32.05,"岁月啊没有捷径",3.0],
- [35.02,"一半努力 一半是运气",3.1],
- [38.08,"无论得到失去",3.0],
- [41.05,"记得有我陪着你",4.0],
- [45.09,"如果有一天 你一贫如洗",4.0],
- [49.06,"就让我做你 最后的行李",3.9],
- [53.01,"看免费的四季",1.1],
- [54.09,"身旁有你我就很富裕",5.9],
- [60.03,"愿得一人心 白首不相离",3.0],
- [63.08,"狂风暴雨我也为你撑起",4.0],
- [67.05,"伴着爱行万里 多远也没有倦意",37.0],
- [104.01,"岁月啊没有捷径",2.1],
- [106.09,"一半努力 一半是运气",4.0],
- [110.05,"无论得到失去",3.0],
- [113.01,"记得有我陪着你",4.0],
- [117.06,"如果有一天 你一贫如洗",4.0],
- [121.03,"就让我做你 最后的行李",3.0],
- [124.07,"看免费的四季",2.0],
- [126.06,"身旁有你我就很富裕",5.0],
- [131.09,"愿得一人心 白首不相离",4.0],
- [135.05,"狂风暴雨我也为你撑起",4.0],
- [139.01,"伴着爱行万里 多远也没有倦意",7.0],
- [146.03,"如果有一天 你一贫如洗",3.1],
- [149.09,"就让我做你 最后的行李",3.9],
- [153.04,"看免费的四季",2.0],
- [155.03,"身旁有你我就很富裕",5.0],
- [160.06,"愿得一人心 白首不相离",4.0],
- [164.02,"狂风暴雨我也为你撑起",3.1],
- [167.08,"伴着爱行万里 多远也没有倦意",7.9],
- [175.03,"谢谢欣赏!",6]
- ];
- let calcKey = () => {for (j = 0;j < lrcAr.length;j++) {if (aud.currentTime <= lrcAr[j][0]) {mKey = j - 1;break;}}if (mKey < 0) mKey = 0;if (mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;let time = lrcAr[mKey][2] - (aud.currentTime - lrcAr[mKey][0]);showLrc(time);};
- let mState = () => papa.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- let showLrc = (time) => {lrc.style.setProperty('--motion', mFlag ? 'cover1' : 'cover2');lrc.style.setProperty('--geci', '"' + lrcAr[mKey][1] + '"');lrc.style.setProperty('--tt', time + 's');mKey += 1;mFlag = !mFlag;};
- aud.addEventListener('play', mState, false);
- aud.addEventListener('pause', mState, false);
- aud.addEventListener('timeupdate', () => {for (j = 0; j < lrcAr.length; j++) {if (aud.currentTime - slip >= lrcAr[j][0]) {cKey = j;if (mKey === j) showLrc(lrcAr[j][2]);else continue;}}});
- mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();
- })();
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|