|
发表于 2024-10-22 11:16:08
|
显示全部楼层
IP:辽宁
- <div style="width: 100%;height: 1050px;position: absolute;MARGIN-LEFT:-210px;MARGIN-top:86px;">
- <style>#papa{
- position: relative;
- width: 1164px;
- height: 640px;
- margin-left:20px;
- margin-top:10px;
- border: 0px solid rgba(36, 201, 219,.95);
- border-radius: 0px;
- background:#000 url(https://pic.imgdb.cn/item/66135afc68eb9357135ffd24.jpg)no-repeat center/cover;
- overflow: hidden;
- }
- .img-container {
- position:absolute;z-index: 1;
- height: 700px;
- width: 800px;
- perspective: 500px;left:250px;
- transform-style: preserve-3d;
- }
- .box {
- width: 620px;
- height: 400px;
- border-radius: 0px;
- overflow: hidden;
- border: 3px solid #ccc;
- position: absolute;
- top: 40%;
- transition: 800ms ease-in-out;
- }
- .box img {
- width: 100%;
- height: 100%;
- }
- .box:first-of-type {
- z-index: 1;
- opacity: 0;
- left: 15%;
- transform: translate(-100%, -100%) rotateY(50deg);
- }
- .box:nth-of-type(2) {
- opacity: 1;
- left: 20%;
- transform: translate(-50%, -50%) rotateY(-10deg);
- z-index: 1;
- }
- .box:nth-of-type(3) {
- left: 25%;
- opacity: 0.90;
- color: #eee;
- z-index: 10;
- transform: translate(-50%, -50%) rotateY(-10deg) translateZ(-40px);
- }
- .box:nth-of-type(4) {
- z-index: 8;
- opacity: 0.80;
- left:30%;
- transform: translate(-50%, -50%) rotateY(-10deg) translateZ(-80px);
- }
- .box:nth-of-type(5) {
- z-index: 7;
- opacity: 0.70;
- left: 35%;
- transform: translate(-50%, -50%) rotateY(-10deg) translateZ(-120px);
- }
- .box:nth-of-type(6) {
- z-index: 6;
- opacity: 0.6;
- left: 40%;
- transform: translate(-50%, -50%) rotateY(-10deg) translateZ(-160px);
- }
- .box:nth-of-type(7) {
- z-index: 5;
- opacity: 0.5;
- left: 45%;
- transform: translate(-50%, -50%) rotateY(-10deg) translateZ(-200px);
- }
- .box:nth-of-type(8) {
- z-index: 4;
- opacity: 0.4;
- left: 50%;
- transform: translate(-50%, -50%) rotateY(-10deg) translateZ(-240px);
- }
- .box:nth-of-type(9) {
- z-index: 3;
- opacity: 0.3;
- left: 55%;
- transform: translate(-50%, -50%) rotateY(-10deg) translateZ(-280px);
- }
- .box:nth-of-type(10) {
- z-index: 2;
- opacity: 0;
- left: 60%;
- transform: translate(-50%, -50%) rotateY(-10deg) translateZ(-320px);
- }
- #mplayer {top:12%; left:5%;cursor: pointer;
- width:200px;text-align:center;animation:rot 10s linear infinite;
- position: absolute;filter:drop-shadow(#000 0px 0 1px);
- z-index: 40;
- }
- @keyframes rot { to { transform: rotate(2turn);} }
- </style>
- <div id="papa">
- <div class="img-container">
- <div class="box">
- <img src="https://pic.imgdb.cn/item/66fb8410f21886ccc0a62100.webp" alt="">
- </div>
- <div class="box">
- <img src="https://pic.imgdb.cn/item/65db13539f345e8d03a32d0b.jpg" alt="">
- </div>
- <div class="box">
- <img src="https://pic.imgdb.cn/item/6673e409d9c307b7e9a64805.webp" alt="">
- </div>
- <div class="box">
- <img src="https://pic.imgdb.cn/item/666909c4d9c307b7e9e71bad.jpg" alt="">
- </div>
- <div class="box">
- <img src="https://pic.imgdb.cn/item/65db15629f345e8d03a78591.jpg" alt="">
- </div>
- <div class="box">
- <img src="https://pic.imgdb.cn/item/65db15639f345e8d03a787ea.jpg" alt="">
- </div>
- <div class="box">
- <img src="https://pic.imgdb.cn/item/66fb8420f21886ccc0a62fe3.webp" alt="">
- </div>
- <div class="box">
- <img src="https://pic.imgdb.cn/item/66fb8419f21886ccc0a628e0.webp" alt="">
- </div>
- <div class="box">
- <img src="https://pic.imgdb.cn/item/6673e4b9d9c307b7e9a78f68.webp" alt="">
- </div>
- <div class="box">
- <img src="https://pic.imgdb.cn/item/6673e506d9c307b7e9a816af.webp" alt="">
- </div>
- </div>
- <div id="mplayer" > <svg width="100" height="100" viewBox="-160 -160 320 320">
- <defs>
- <filter id="shadow">
- <feDropShadow dx="0" dy="0" stdDeviation="1" flood-color="black"></feDropShadow>
- </filter>
- <g id="part" filter="url(#shadow)">
- <line x1="0" y1="-100" x2="0" y2="100" stroke="#880" stroke-width="4"></line>
- <ellipse cx="0" cy="-125" rx="20" ry="20" fill="#fff"></ellipse>
- <ellipse cx="0" cy="125" rx="20" ry="20" fill="#fff"></ellipse>
- </g>
- </defs>
- <use href="#part"></use>
- <use href="#part" transform="rotate(35)"></use>
- <use href="#part" transform="rotate(70)"></use>
- <use href="#part" transform="rotate(105)"></use>
- <use href="#part" transform="rotate(140)"></use>
- </svg></div>
- <div data-lrc="亚伦影音工作室" id="lrc">亚伦影音工作室</div>
- <audio id="aud" src="https://s2.ananas.chaoxing.com/sv-w7/audio/b5/0f/de/6615a1eb78f58c680fc5ea73f913e316/audio.mp3" autoplay="" loop="loop"></audio>
- </div>
- <style type="text/css">
- #lrc {
- --state: paused;
- --motion: cover2;
- --tt: 2s;
- --bg: #880000;
- position: absolute;z-index: 4;
- left: 50%;
- transform: translate(-50%);
- top: 84%;
- font:normal 3em 华文隶书;
- color: #000;
- white-space: pre;
- -webkit-background-clip: text;
- filter:drop-shadow(#FFFFFF 1px 0 0)drop-shadow(#FFFFFF 0 1px 0)drop-shadow(#FFFFFF -1px 0 0) drop-shadow(#FFFFFF 0 -1px 0);
- }
- #lrc::before {
- position: absolute;
- content: attr(data-lrc);
- width: 20%;
- height: 100%;
- color: transparent;
- overflow: hidden;
- white-space: pre;
- background: var(--bg);
-
- -webkit-background-clip: text;
- animation: var(--motion) var(--tt) linear forwards;
- animation-play-state: var(--state);
- }
- @keyframes cover1 { from { width: 0; } to { width: 100%;} }
- @keyframes cover2 { from { width: 0;} to { width: 100%;} }
- </style>
- <script>
- let imgContainer = document.querySelector(".img-container");
- setInterval(() => {
- if(!aud.paused){
- let last = imgContainer.firstElementChild;
- last.remove();
- imgContainer.appendChild(last);}
- }, 2500);
- </script>
- <script>
- mplayer.onclick = () => aud.paused ? (aud.play()): (aud.pause());
- aud.addEventListener('playing', () =>mplayer.style.animationPlayState = 'running');
- aud.addEventListener('pause', () =>mplayer.style.animationPlayState = 'paused');
- </script>
- <script >
- (function() {
- /*原始lrc歌词*/
- let lrcStr = `[00:01.29]你别哭 你别哭
- [00:04.95]我知道你走的很辛苦
- [00:08.79]那种身心上的疲惫和无助
- [00:12.78]是旁人感受不到的难处
- [00:31.41]我知道 你坚强的背后
- [00:35.10]一定藏着很多脆弱
- [00:38.85]我知道 你懂事的背后
- [00:42.63]一定藏着很多失落
- [00:46.35]我知道 你笑容的背后
- [00:50.10]一定藏着很多难过
- [00:53.88]有时候会莫名眼泪滑落
- [00:57.96]却不知该怎么诉说
- [01:02.96]因为代码太长所以只好把歌词删掉一部分
- `;
- /*变量 :mKey - 当前歌词索引;mFlag :调用关键帧动画索引;averAdd :平均值补偿*/
- let mKey = 0, mFlag = true, averAdd = 0.3;
- /*函数 :获取每句歌词用时,歌词用时若超过平均值则取平均值,最后一句歌词则取平均值*/
- let lrcTime = (ar) => {
- let tmpAr = [];
- for(j = 0; j <ar.length - 1; j ++) {
- if(j !== ar.length - 1) tmpAr[j] = parseFloat((ar[j+1][0] - ar[j][0]).toFixed(1));
- }
- let aver = parseInt(tmpAr.reduce((a,b) => a + b) / (tmpAr.length - 1)) + averAdd;
- tmpAr.push(aver);
- tmpAr.forEach((item,key) => {
- ar[key][2] = item > aver ? aver : item;
- });
- return ar;
- };
- /*函数 :从原始lrc歌词获取信息并存入 n*3 数组*/
- let getLrcAr = (text) => {
- let lrcAr = [];
- let calcRule = [60,1,0.001];
- for(x of text.split('\n')) {
- let ar = [];
- let re = /\d+[\.:]\d+([\.:]\d+)?/g;
- let geci = x.replace(re,'');
- if(geci) {
- geci = geci.replace(/[\[\]\'"\t,]s?/g,'');
- let time = x.match(re);
- if(time != null) {
- for(y of time) {
- let tmp = y.match(/\d+/g);
- let sec = 0;
- for(z in tmp) sec += tmp[z] * calcRule[z];
- ar[0] = [parseFloat(sec.toFixed(2)), geci];
- lrcAr.push(ar[0]);
- }
- }
- }
- }
- lrcAr.sort((a,b)=> a[0] - b[0]);
- return(lrcTime(lrcAr));
- };
- /*函数 :模拟显示同步歌词*/
- let showLrc = (time) => {
- let name = mFlag ? 'cover1' : 'cover2';
- lrc.innerHTML = lrcAr[mKey][1];
- lrc.dataset.lrc = lrcAr[mKey][1];
- lrc.style.setProperty('--motion', name);
- lrc.style.setProperty('--tt', time + 's');
- lrc.style.setProperty('--state', 'running');
- mKey += 1;
- mFlag = !mFlag;
- };
- /*函数 :处理当前歌词索引 mKey*/
- 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 toMin = (val) => {
- if (!val) return '00:00';
- val = Math.floor(val);
- let min = parseInt(val / 60),
- sec = parseFloat(val % 60);
- if (min < 10) min = '0' + min;
- if (sec < 10) sec = '0' + sec;
- return min + ':' + sec;
- }
- /*函数 :关键帧动画状态切换*/
- let mState = () => aud.paused ? (lrc.style.setProperty('--state','paused'),mplayer.style.animationPlayState = 'paused') : (lrc.style.setProperty('--state','running'),mplayer.style.animationPlayState = 'running');
- /*监听播放进度*/
- aud.addEventListener('timeupdate', () => {
- for (j = 0; j < lrcAr.length; j++) {
- if (aud.currentTime >= lrcAr[j][0]) {
- cKey = j;
- if (mKey === j) showLrc(lrcAr[j][2]);
- else continue;
- }
- }
- });
- aud.addEventListener('pause', () => mState());/*监听暂停事件*/
- aud.addEventListener('play', () => mState());/*监听播放事件*/
- aud.addEventListener('seeked', () => calcKey());/*监听查询事件*/
- let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
- })();
- </script>
- </div>
- <div style="width: 100%;height: 780px;"> </div>
复制代码
|
|