楼主: 司敏儿

[单图] 复刻(站得太久) (凡哥代码)

[复制链接]
发表于 2024-6-17 11:49 | 显示全部楼层
令狐冲 发表于 2024-6-14 23:46
我看不到图。。。


你去我这里看看,图片是否出来:http://mhh.52qingyin.cn/art/bsho ... rt=mahei_1717816702

背景图片:https://638183.freep.cn/638183/t24/2/dahe.jpg

另外,我想知道你使用的浏览器是什么、版本号是多少
点评
回复

使用道具

 楼主| 发表于 2024-6-17 13:09 | 显示全部楼层
花简静 发表于 2024-6-16 23:15
敏儿人呢,今天没有看到耶

我在,今天有些忙工作
点评
回复

使用道具

 楼主| 发表于 2024-6-17 13:12 | 显示全部楼层
本帖最后由 司敏儿 于 2024-6-17 16:57 编辑


凡哥老师,

https://638183.freep.cn/638183/t24/2/dahe.jpg 图片手机上不能显示  (Safari )
点评
回复

使用道具

 楼主| 发表于 2024-6-17 13:14 | 显示全部楼层
本帖最后由 司敏儿 于 2024-6-17 13:43 编辑
  1. <style>
  2. #tz { margin: 30px auto; width: 1024px; height: 640px; overflow: hidden; display: grid; place-items: center; position: relative; }
  3. #tz::before { position: absolute; content: ''; width: var(--size); height: var(--size); background: linear-gradient(cyan, olive, orange, navy); animation: spin 12s linear infinite var(--state); }
  4. #nr { position: absolute; padding: 10px; background: url('https://638183.freep.cn/638183/t24/2/dahe.jpg') no-repeat center/cover; inset: 6px; }
  5. txt-box { position: absolute; display: grid; place-items: center; left: var(--xx); bottom: 0; width: 50px; height: 50px; font: normal 30px sans-serif; color: white; transition: .5s; cursor: pointer; animation: move 5s var(--delay) linear infinite alternate var(--state); }
  6. txt-box::after { position: absolute; content: ''; inset: -6px; border: thick groove olive; border-radius: 50%; box-shadow: inset 0 0 30px lightblue; transform: perspective(1000px) rotateY(-60deg) rotateZ(0); animation: rot 5s var(--delay) linear infinite alternate var(--state); }
  7. txt-box:hover { filter: hue-rotate(60deg) drop-shadow(0 -10px 30px white); }
  8. #vid { position: absolute; left: 0; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; mix-blend-mode: darken; pointer-events: none; }
  9. #bird { position: absolute; left: 1024px; top: -70px; mix-blend-mode: multiply; animation: fly linear 6s infinite var(--state); }
  10. @keyframes move { to { bottom: 150px; } }
  11. @keyframes rot { to { transform: perspective(1000px) rotateY(60deg) rotateZ(360deg); } }
  12. @keyframes spin { to { transform: rotate(360deg); } }
  13. @keyframes fly { to { left: -400px; } }
  14. </style>

  15. <div id="tz">
  16.         <div id="nr" data-tt="大河悠久">
  17.                 <audio id="aud" src="https://music.163.com/song/media/outer/url?id=4904991" autoplay loop></audio>
  18.                 <video id="vid" src="https://img.tukuppt.com/video_show/2418175/01/32/44/62dde814a8a83.mp4" muted autoplay loop disablePictureInPichture></video>
  19.                 <img id="bird" alt="" src="https://638183.freep.cn/638183/small/flybirds.gif" />
  20.         </div>
  21. </div>

  22. <script>
  23. (function() {
  24.         tz.style.setProperty('--size', Math.ceil(Math.sqrt(tz.offsetWidth ** 2 + tz.offsetHeight ** 2)) + 'px');
  25.         const ar = nr.dataset.tt.split('');
  26.         const total = ar.length, half = Math.floor(ar.length / 2);
  27.         let tbAr = [];

  28.         ar.forEach((t,k) => {
  29.                 let tbox = document.createElement('txt-box');
  30.                 tbox.textContent = t;
  31.                 tbox.style.cssText += `
  32.                         --xx: ${100 * k + 50}px;
  33.                         --delay: -${k <= half ? k * 0.5 : (total - k) * 0.5}s;
  34.                 `;
  35.                 tbAr.push(tbox);
  36.                 nr.appendChild(tbox);
  37.         });

  38.         aud.onplaying = aud.onpause = () => {
  39.                 tz.style.setProperty('--state', ['running','paused'][+aud.paused]);
  40.                 aud.paused ? vid.pause() : vid.play();
  41.                 tbAr.forEach(item => item.title = ['暂停','播放'][+aud.paused]);
  42.         };

  43.         tbAr.forEach(item => item.onclick = () => aud.paused ? aud.play() : aud.pause());
  44. })();
  45. </script>
复制代码
点评
回复

使用道具

 楼主| 发表于 2024-6-17 13:16 | 显示全部楼层
#nr { position: absolute; padding: 10px; background: url('https://642303.freep.cn/642303/tu/20240608ty06.webp') no-repeat center/cover; inset: 6px;z-index: 2; }

因为音画背景 加载在 #nr    有部分浏览器 此处强调  宽,高 尺寸,才能显示
点评
回复

使用道具

发表于 2024-6-17 19:41 | 显示全部楼层
司敏儿 发表于 2024-6-17 13:12
凡哥老师,

https://638183.freep.cn/638183/t24/2/dahe.jpg 图片手机上不能显示  (Safari ) ...

酱紫,手机浏览器不要用系统自带的,可以在应用商店下一个好用的,Chrome不错,edge也非常有些。一般地,我们建议使用edge浏览器,它目前没有什么限制。
点评
回复

使用道具

发表于 2024-6-17 19:46 | 显示全部楼层
司敏儿 发表于 2024-6-17 13:16
#nr { position: absolute; padding: 10px; background: url('https://642303.freep.cn/642303/tu/20240608 ...

嗯,低内核的浏览器还不支持 inset 属性。该属性,以 inset: 6px; 为例,是如下四个属性的简写:

top: 6px;
right: 6px;
bottom: 6px;
left: 6px;

不一定要表达 width 和 height 属性,上面的代码约束子元素的位置,当父元素是 relative 定位,子元素是 absolute 定位,那么,子元素的宽高等于:

width: 父元素宽 - 12
height: 子元素 - 12

当然,可以定义子元素的宽高,然后用 top: 6px; left: 6px; 来定位

评分

1

查看全部评分

点评
回复

使用道具

 楼主| 发表于 2024-6-17 19:57 | 显示全部楼层
凡哥 发表于 2024-6-17 19:46
嗯,低内核的浏览器还不支持 inset 属性。该属性,以 inset: 6px; 为例,是如下四个属性的简写:

top: 6 ...

我先消化消化。。
点评
回复

使用道具

 楼主| 发表于 2024-6-17 19:57 | 显示全部楼层
兼容模式,不显示
点评
回复

使用道具

 楼主| 发表于 2024-6-17 19:58 | 显示全部楼层
3D  旋转,手机上只有一个花瓣
点评
回复

使用道具

您需要登录后才可以回帖 登录 | 中文注册

本版积分规则

手机版|千山论坛 ( 冀ICP备2024055714号 )

GMT+8, 2025-6-10 05:14

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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