找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
楼主: 老谟深虑

学习代码音画《烟雨江南》

[复制链接]

200

主题

1万

回帖

5万

积分

超级版主

积分
51152
发表于 2024-6-25 18:07:55 | 显示全部楼层 IP:河北廊坊
老谟深虑 发表于 2024-6-25 15:22
谢谢支持和评精鼓励,页面是有问题,我调了,也没有调到最好。下午好!
...

是向左多了。

245

主题

1万

回帖

5万

积分

版主

积分
58087
 楼主| 发表于 2024-6-25 18:12:50 | 显示全部楼层 IP:亚太地区
本帖最后由 老谟深虑 于 2024-6-25 18:20 编辑

       我再去调调。调后开始审核了。

200

主题

1万

回帖

5万

积分

超级版主

积分
51152
发表于 2024-6-25 18:24:52 | 显示全部楼层 IP:河北廊坊
烟雨江南

200

主题

1万

回帖

5万

积分

超级版主

积分
51152
发表于 2024-6-25 18:27:12 | 显示全部楼层 IP:河北廊坊
老谟,上面是我调整的,把向左调整为0就好了。
  1. <div style="width: 100%;height: 1050px;position: absolute;MARGIN-LEFT:0px;MARGIN-top:50px;">
  2. <style>
  3. #tz { margin: 30px 0 30px calc(40% - 700px); width: 1400px; height: 800px; background: url('https://sirius.130014.xyz/2024/06/18/3-220929163459_.jpg') no-repeat center/cover; box-shadow: 2px 2px 6px gray; overflow: hidden; position: relative; }
  4. #lrc { position: absolute; left: 120px; top: 715px; font: normal 40px sans-serif; white-space: nowrap; color: Yellow; text-shadow: 1px 1px 1px gray; animation: fly 20s linear infinite alternate var(--state); --ww: 350px; }
  5. #player { position: absolute;top: 680px; left: calc(58% - 140px); bottom: 20px; width: 280px; height:10px; background: linear-gra**nt(to right, var(--color) var(--prg), transparent 0); border: 1px solid var(--color); border-radius: 6px; display: grid; place-items: center; --color: green; --prg: 0%; --btnSize: 50px;}
  6. #player::before, #player::after { position: absolute; content: ''; }
  7. #player::before { width: var(--btnSize); height: var(--btnSize); top: calc(#FFA500 * -1 - 5px); background: url('https://pic.imgdb.cn/item/666c48a7d9c307b7e9370e89.png') no-repeat center/cover; filter: hue-rotate(180deg); animation: rot 6s linear infinite var(--state);}
  8. #player::after { content: attr(data-time); inset: -30px 0 10px 0; text-align: justify; text-align-last: justify; font-size: 14px; color: #FFA500; pointer-events: none; }
  9. .vid { position: absolute; bottom: 0; width: 100%; height: calc(100% + 60px); object-fit: cover; mix-blend-mode: screen; pointer-events: none; }
  10. @keyframes rot { to { transform: rotate(360deg); } }
  11. @keyframes fly { to { left: calc(100% - var(--ww) - 20px); } }
  12. </style>

  13. <div id="tz">
  14.         <audio id="aud" src="https://music.163.com/song/media/outer/url?id=321939" autoplay loop></audio>
  15.         <video class="vid" src="https://img.tukuppt.com/video_show/15653652/00/80/83/60d04564c32f7.mp4" autoplay loop muted></video>
  16.         <div id="lrc">烟雨江南</div>
  17.         <div id="player" data-time="00:00 00:00"></div>
  18. </div>

  19. <script>
  20. var vids = document.querySelectorAll('.vid');
  21. var btnSize = parseInt(window.getComputedStyle(player).getPropertyValue('--btnSize'));

  22. var lrcKey = 0;

  23. var showLrc = () => {
  24.         if(lrcKey >= lrcAr.length) return false;
  25.         lrc.innerText = lrcAr[lrcKey][1];
  26.         lrc.style.setProperty('--ww', lrc.offsetWidth + 'px');
  27.         lrcKey ++;
  28. };

  29. var mState = () => {
  30.         tz.style.setProperty('--state',['running','paused'][+aud.paused]);
  31.         if(vids.length > 0) vids.forEach(vid => aud.paused ? vid.pause() : vid.play());
  32. };

  33. var s2m = (s) => (Math.floor(s / 60)).toString().padStart(2, '0') + ':' + (Math.floor(s % 60)).toString().padStart(2, '0');

  34. aud.onplaying = aud.onpause = () => mState();

  35. aud.onseeked = () => {
  36.         for(var j = 0; j < lrcAr.length; j ++) {
  37.                 if(aud.currentTime < lrcAr[j][0]) {
  38.                         lrcKey = j - 1;
  39.                         if(lrcKey < 0) lrcKey = 0;
  40.                         break;
  41.                 }
  42.         }
  43. };

  44. aud.ontimeupdate = () => {
  45.         player.style.setProperty('--prg', (aud.currentTime / aud.duration * 100 || 0) + '%');
  46.         player.dataset.time = s2m(aud.currentTime) + ' ' + s2m(aud.duration);
  47.         if(lrcKey <= lrcAr.length - 1 && aud.currentTime >= lrcAr[lrcKey][0]) showLrc();
  48. }

  49. player.onclick = (e) => {
  50.         if(e.offsetY > 0) aud.currentTime = aud.duration * e.offsetX / player.offsetWidth;
  51.         if(e.offsetY < 0 && e.offsetX > player.offsetWidth / 2 - btnSize / 2 && e.offsetX < player.offsetWidth / 2 + btnSize / 2) aud.paused ? aud.play() : aud.pause();
  52. }

  53. player.onmousemove = (e) => {
  54.         if(e.offsetY < 0) {
  55.                 if(e.offsetX > player.offsetWidth / 2 - btnSize / 2 && e.offsetX < player.offsetWidth / 2 + btnSize / 2) {
  56.                         player.title = aud.paused ? '播放' : '暂停';
  57.                         player.style.cursor = 'pointer';
  58.                 }
  59.         }else{
  60.                 player.title = '调节进度';
  61.                 player.style.cursor = 'pointer';
  62.         }
  63. };

  64. var lrcAr = [['22.44','在江南绵绵的雨季里'],
  65.         ['27.49','飘洒着濛濛的细雨'],
  66.         ['32.58','如烟的杨柳在雨中沐浴'],
  67.         ['38.43','杨柳缠绵雨的情意'],
  68.         ['42.97','在青石铺就的街巷里'],
  69.         ['48.30','流淌着道道的雨溪'],
  70.         ['53.50','淡淡的炊烟在雨中升起'],
  71.         ['59.80','夜雨沉醉春的旋律'],
  72.         ['63.57','江南的雨柔柔的江南雨'],
  73.         ['69.00','你用温情滋润着爱的春意'],
  74.         ['74.40','江南的雨江南的秀丽'],
  75.         ['79.72','一江春水梦幻迷离'],
  76.         ['84.90','江南的雨柔柔的江南雨'],
  77.         ['89.46','你用温情滋润着爱的春意'],
  78.         ['94.67','江南的雨江南的秀丽'],
  79.         ['100.22','一江春水梦幻迷离'],
  80.         ['125.75','在江南绵绵的雨季里'],
  81.         ['130.64','飘洒着濛濛的细雨'],
  82.         ['136.69','如烟的杨柳在雨中沐浴'],
  83.         ['141.79','杨柳缠绵雨的情意'],
  84.         ['147.09','在青石铺就的街巷里'],
  85.         ['151.63','流淌着道道的雨溪'],
  86.         ['156.57','淡淡的炊烟在雨中升起'],
  87.         ['162.44','夜雨沉醉春的旋律'],
  88.         ['166.99','江南的雨柔柔的江南雨'],
  89.         ['171.93','你用温情滋润着爱的春意'],
  90.         ['178.59','江南的雨江南的秀丽'],
  91.         ['183.57','一江春水梦幻迷离'],
  92.         ['187.48','江南的雨柔柔的江南雨'],
  93.         ['192.58','你用温情滋润着爱的春意'],
  94.         ['198.50','江南的雨江南的秀丽'],
  95.         ['203.67','一江春水梦幻迷离'],
  96.         ['208.26','江南的雨江南的秀丽'],
  97.         ['214.70','一江春水梦幻迷离']
  98. ];
  99. </script>
  100. </div>
  101. <div style="width: 100%;height: 980px;"> </div>
  102. <p> </p>
  103. <p> </p>
  104. <p> </p>
  105. <p> </p>
  106. <p> </p>
  107. <p> </p>
复制代码

200

主题

1万

回帖

5万

积分

超级版主

积分
51152
发表于 2024-6-25 18:29:43 | 显示全部楼层 IP:河北廊坊
老谟深虑 发表于 2024-6-25 18:12
我再去调调。调后开始审核了。

我已经调整好了。

245

主题

1万

回帖

5万

积分

版主

积分
58087
 楼主| 发表于 2024-6-25 18:36:34 | 显示全部楼层 IP:亚太地区

       谢谢老乡,我调错了,我调下面的数了 ,我没调上面的。

245

主题

1万

回帖

5万

积分

版主

积分
58087
 楼主| 发表于 2024-6-25 18:40:59 | 显示全部楼层 IP:亚太地区

       我按你的已经修改了。

200

主题

1万

回帖

5万

积分

超级版主

积分
51152
发表于 2024-6-25 19:11:28 | 显示全部楼层 IP:河北廊坊
老谟深虑 发表于 2024-6-25 18:40
我按你的已经修改了。

已经好了,我主要把向左偏移变成0,就是不向左移动,画面就好了。

245

主题

1万

回帖

5万

积分

版主

积分
58087
 楼主| 发表于 2024-6-25 19:13:00 | 显示全部楼层 IP:亚太地区
咕咚来了 发表于 2024-6-25 19:11
已经好了,我主要把向左偏移变成0,就是不向左移动,画面就好了。

       学习了。晚上好!

200

主题

1万

回帖

5万

积分

超级版主

积分
51152
发表于 2024-6-25 19:14:33 | 显示全部楼层 IP:河北廊坊
老谟深虑 发表于 2024-6-25 18:36
谢谢老乡,我调错了,我调下面的数了 ,我没调上面的。

其他全正常,只有位置偏了。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|离退休论坛 ( 浙B2-20100176 )

GMT+8, 2024-8-26 13:01 , Processed in 0.079179 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表