|
|

楼主 |
发表于 2024-6-14 08:10
|
显示全部楼层
本帖最后由 马黑黑 于 2024-6-14 08:48 编辑
帖子代码
- <style>
- #tz { margin: 30px 0 30px calc(50% - 721px); width: 1280px; height: 750px; background: lightblue; box-shadow: 3px 3px 6px rgba(0,0,0,.6); overflow: hidden; user-select: none; z-index: 1; perspective: 2000px; position: relative; }
- #picbox { position: absolute; opacity: .8; border-radius: 20px; transform-style: preserve-3d; cursor: pointer; }
- #vid { position: absolute; bottom: 0; width: 100%; height: calc(100% + 65px); object-fit: cover; pointer-events: none; }
- </style>
- <div id="tz">
- <video id="vid" src="https://img.tukuppt.com/video_show/2418175/00/01/83/5b4b0c1e236a1.mp4" autoplay loop muted disablePictureInPicture></video>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1411157155" autoplay loop></audio>
- <img id="picbox" src="https://638183.freep.cn/638183/small/hxxb.webp" alt="" />
- </div>
- <script>
- (function() {
- const pics = new Array(5).fill(0).map((_,k) => 'https://638183.freep.cn/638183/t24/3/dh' + (k+1) + '.jpeg');
- let ani, ar = [];
- const loadImages = async urls => {
- const promises = [];
- for (let url of urls) {
- promises.push(new Promise(resolve => {
- const img = new Image();
- img.onload = () => {
- ar.push([`${img.src}`, `${img.naturalWidth}`, `${img.naturalHeight}`]);
- resolve();
- };
- img.src = url;
- }));
- }
- await Promise.all(promises);
- showPic();
- };
- const showPic = () => {
- let idx = Math.floor(Math.random() * pics.length);
- let w1 = tz.offsetWidth, h1 = tz.offsetHeight, w2 = ar[idx][1], h2 = ar[idx][2];
- let x = Math.random() > 0.5 ? w1 : -w1, y = Math.random() > 0.5 ? h1 : -h2;
- picbox.src = ar[idx][0];
- const kfs = [
- {left: `${x}px`, top: `${y}px`},
- {left: `${(w1 - w2) / 2}px`, top: `${(h1 - h2) / 2}px`, transform: `rotateY(0)`, offset: 0.1},
- {transform: `rotateY(-15deg)`},
- {transform: `rotateY(0)`},
- {transform: `scale(1.2)`},
- {transform: `scale(0.8)`},
- {transform: `rotateY(15deg)`},
- {left: `${(w1 - w2) / 2}px`, top: `${(h1 - h2) / 2}px`, transform: `rotateY(0)`, offset: 0.9},
- {left: `${x}px`, top: `${y}px`, transform: `rotateZ(180deg) scale(0)`},
- ];
- ani = picbox.animate(kfs, 10000);
- ani.onfinish = () => showPic();
- };
- picbox.onclick = () => aud.paused ? (aud.play(), ani.play()) : (aud.pause(), ani.pause());
- picbox.onmouseover = () => { if(!aud.paused) ani.pause(); };
- picbox.onmouseout = () => { if(!aud.paused) ani.play(); };
- loadImages(pics);
- })();
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|