亚伦影音工作室 发表于 2024-3-28 15:24

纯代码制作背景首尾无缝连接

本帖最后由 亚伦影音工作室 于 2024-3-29 15:25 编辑 <br /><br /><style>
#papa{margin: 150px -300px;
        width: 1164px;
        height: 620px;
        background:url(https://pic.imgdb.cn/item/66051d0b9f345e8d03554251.jpg)no-repeat center/cover;
        box-shadow: 0px 0px 0px 2px #cccccc, 0px 0px 0px 8px #880000;
        position: relative;overflow: hidden;
        z-index: 12345; }
      #geci{width: 100%;
font: normal 3em/0em 华文隶书;
      color: #ff0000;
       filter:drop-shadow(#ffffff 1px 0 0)drop-shadow(#ffffff 0 1px 0)drop-shadow(#ffffff -1px 0 0) drop-shadow(#ffffff 0 -1px0);
      text-align:center;
       position: absolute; pointer-events: none;
      z-index: 10;
}
#wzsd1 { animation: wzsd 0.56s linear infinite ; position:absolute;width:100%;height:80px; z-index: 10;    top:90%; }
@keyframes wzsd {
from {opacity: 1;filter:hue-rotate(360deg)contrast(180%)brightness(200%);}
50% {opacity: 1;}
to {opacity: 1;filter:hue-rotate(0deg)contrast(140%)brightness(100%);}}

#papa:hover #fullscreen { display:block ;opacity: 1;}
#fullscreen { position: absolute; top:5%; left:calc(95% - 15px);font: normal 2em/0em 楷体;color:#ffffff; opacity: 1; cursor: pointer; z-index: 111}
</style>
<style>

#gj {top:20%; left:40%;z-index: 21;
position: absolute;overflow: hidden;transform:scale(0.4);
width: 100%;
height: 100%;}
#pic {top:20%; left:5%;z-index: 20;
position: absolute;
width: 350px;
height: 350px;
border-radius: 50%;
border:2px solid #000000;
background:url('https://pic.imgdb.cn/item/642d9c53a682492fcccad99f.png') center/cover no-repeat,url('https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/b0bea37f1dff1ba2977e3d3cdf8cf8ea.jpg')30px 50px/100% 60%;
animation: spin 10s infinite linear ;}
@keyframes spin {100% { transform: rotate(360deg); }
}

#mplayer {position: absolute;
      top:2%; left:0%;z-index: 21;
      width: 500px;
      height: 500px;
      cursor: pointer;
}
.pink { background: url('https://pic.imgdb.cn/item/642e1dcea682492fcc4d5bb1.png')no-repeat center/cover;transform:rotate(-2deg);transform-origin: 100% 0%;}
.purple { background: url('https://pic.imgdb.cn/item/642e1dcea682492fcc4d5bb1.png')no-repeat center/cover; transform-origin: 75% 0%;margin: 25px -32px;transform:rotate(-20deg);}
#tmsg {position: absolute;z-index: 20;
      font: normal 25px sans-serif;
      color: #ffffff;
         top:500px;
      left:14%;}
#prog {position: absolute;z-index: 91;
      width: 80%;
      height: 0.3%;
      cursor: pointer;
         top:95%;

      margin:0px 10%;
border-radius: 2px;}
</style>

<div id="papa" >
<span id="fullscreen">全屏</span>
<div id="wzsd1" >
<div id="geci" ></div>
</div>
<audio id="aud"autoplay="autoplay" ></audio>
<ol style="width:380px;height:200px;color:#00ff00;position:absolute;left:30px;top:24px;font: normal 1.2em/2em 仿宋;cursor:pointer;z-index: 20; "></ol>
<divid="prog"></div>
        <div id="gj" >
<div id="pic" ></div>
<div id="mplayer" class="pink"></div>
<div id="tmsg">00:00 | 00:00</div>
</div>
<div id="testImg" >
<div class="photo" > <img   src="https://pic.imgdb.cn/item/66051da19f345e8d035829f5.jpg" style="transform: rotateY(0deg);width:100%;height:100%" /></div>
<div class="photo" > <img   src="https://pic.imgdb.cn/item/66051da19f345e8d035829f5.jpg" style="transform: rotateY(180deg);width:100%;height:100%" /></div>

</div>



<script >

var lrc= []
lrc = [,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
       

];

      var videoArray = [
["https://p4.t57.cn:8399/2021/zw/2/GMV.m4a","最远的你是我最近的爱dj(孙艺琪)"]
      ];
      var items = []
      var olObj = document.querySelector('ol');
      for(i = 0 ; i < videoArray.length; i++)      {
                oli = document.createElement('li');
                oTxt = document.createTextNode(videoArray);
                oli.appendChild(oTxt);
                olObj.appendChild(oli);
                items = oli;
      }

       geci = document.querySelector('#geci')
      var player = document.querySelector('#aud');
      var curIdx = 0;
      player.focus();
      player.src = videoArray;
      items.style.color = 'red';
               ;
player.addEventListener("timeupdate", myFunction);
function myFunction() {
      for(j=0; j<lrc.length; j++){
                if(player.currentTime >= lrc){
                        geci.innerHTML = lrc;
                }
      }
}
      player.onended = function()      {
                items.style.color = '#ffffff';
                player.pause();
                curIdx++;
                if(curIdx >= items.length) curIdx = 0;
                player.src = videoArray;
                items.style.color = '#ff0000';
                player.play();
      }
      for(n = 0; n < items.length; n++)      {
                items.onclick = function()      {
                        player.pause();
                        items.style.color = '#00f000';
                        for(j = 0; j < items.length; j++)      {
                              if(this.innerHTML == videoArray)      {
                                        player.src = videoArray;
                                        this.style.color = 'red';
                                        curIdx = j;
                                        break;
                              }
                        }
                        player.play();
                }
      };

mplayer.style.animationPlayState = aud.paused ? 'paused' : 'running';
aud.addEventListener('playing', () => mplayer.style.animationPlayState = 'running');
aud.addEventListener('pause', () =>mplayer.style.animationPlayState = 'paused');

mplayer.addEventListener('click', () => aud.paused ? (aud.play(),mplayer.classList.remove('purple')) : (aud.pause(),mplayer.classList.add('purple')));
aud.addEventListener('play', () => mState());
aud.addEventListener('pause', () => mState());


pic.style.animationPlayState = aud.paused ? 'paused' : 'running';
aud.addEventListener('playing', () =>pic.style.animationPlayState = 'running');
aud.addEventListener('pause', () =>pic.style.animationPlayState = 'paused');


wzsd1.style.animationPlayState = aud.paused ? 'paused' : 'running';
aud.addEventListener('playing', () =>wzsd1.style.animationPlayState = 'running');
aud.addEventListener('pause', () =>wzsd1.style.animationPlayState = 'paused');
prog.onclick = (e) => {
                aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;
      }
aud.addEventListener('timeupdate', () => {
               aud.addEventListener('timeupdate', () => {prog.style.background= 'linear-gradient(90deg, red, red, red ' + aud.currentTime / aud.duration * 100 + '%, snow 0)';});
                tmsg.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);

      });
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;
      };

</script>

<style>
.photo {width: 100%;
height: 100%;
position: absolute;
z-index: 1;
top:0px; left:0%;
opacity: 1;
animation: round 12s linear infinite;}
@keyframes round{0% {opacity: 1;transform:translate(100%,0%)scale(1) ;}
100% {opacity: 1;transform:translate(-100%,0%)scale(1) ;}
}

.photo:nth-child(2) {animation-delay: 6s;}
.photo:nth-child(1) {animation-delay: 0s;}

.stop .photo:nth-child(1),
.stop .photo:nth-child(2){animation-play-state: paused;}
</style>

<script>
/*控制动画*//*控制动字*/
(function(){
var image = document.getElementById("testImg");

let mState = () => aud.paused ? (image.classList.add('stop')):(image.classList.remove('stop'));
aud.addEventListener('play', () => mState());
aud.addEventListener('pause', () => mState());
})();
/*结束*//*结束*/
let fs = true;
      fullscreen.onclick = () => {
                fs ? (fullscreen.innerText = '退出', papa.requestFullscreen()) : (fullscreen.innerText = '全屏', document.exitFullscreen());
                fs = !fs;
      };

</script>

红影 发表于 2024-3-28 18:50

好漂亮的制作。欣赏亚伦老师好帖{:4_199:}

小文 发表于 2024-3-28 20:27

好漂亮{:4_180:}

庶民 发表于 2024-3-29 09:02

太漂亮。

亦是金 发表于 2024-3-29 09:13

我听不见歌曲,在本地也没有声音!更换歌曲后就正常了。{:4_180:}
页: [1]
查看完整版本: 纯代码制作背景首尾无缝连接