|
楼主 |
发表于 2024-4-10 12:33:49
|
显示全部楼层
IP:亚太地区
- <style>
- #mydiv {
- margin: 120px 0 0 calc(50% - 483px);
- width: 1302px;
- height: 753px;
- background: lightgreen url('https://s21.ax1x.com/2024/04/09/pFOKF1O.jpg') no-repeat center/cover;
- box-shadow: 4px 4px 8px gray;
- box-sizing: border-box;
- overflow: hidden;
- z-index: 1;
- position: relative;
- }
- #mydiv::before , #mydiv::after {
- position: absolute;
- content: '';
- left: var(--begin1);
- top: 0px;
- width: 100%;
- height: 100%;
- background: url('https://s21.ax1x.com/2024/04/09/pFOKF1O.jpg') no-repeat center/cover;
- z-index: -1;
- }
- #mydiv::after {
- left: var(--begin2);
- transform: scale(-1,1);
- }
- #play {
- position: absolute;
- left: calc(50% - 50px);
- bottom: 10px;
- width: 100px;
- cursor: pointer;
- animation: rotating 5s linear infinite var(--state);
- }
- @keyframes rotating { to { transform: rotate(360deg); } }
- #dt2{ position: absolute; width:305px; height: 242px; top: 370px; left: 500px; }
- #dt3{ position: absolute; width: 201px; height: 109px; top: 20px; left: 300px; }
- </style>
- <div id="mydiv">
- <img id="dt2" src="https://pic.imgdb.cn/item/66151ada68eb935713469028.gif" alt="" />
- <img id="dt3" src="https://pic.imgdb.cn/item/6615150c68eb9357133d5b5d.gif" alt="" />
- <audio id="aud" src="https://file.uhsea.com/2404/771c6568cd4c7db6b229d135ea4d42acH6.mp3" autoplay></audio>
- <img id="play" src="https://pic.imgdb.cn/item/661013c568eb93571345cc0c.png" alt="" />
- </div>
- <script>
- var ww = mydiv.offsetWidth;
- var step = 0.2, begin1 = 0, begin2 = -ww, raf;
- aud.loop = false;
- aud.onpause = aud.onplaying = () => moving();
- aud.onseeked = () => cancelAnimationFrame(raf);
- aud.onended = () => { cancelAnimationFrame(raf); aud.play(); };
- play.onclick = () => { aud.paused ? aud.play() : aud.pause(); };
- var moving = () => {
- begin1 += step;
- begin2 += step;
- if(begin1 >= ww) begin1 = -ww;
- if(begin2 >= ww) begin2 = -ww;
- mydiv.style.setProperty('--begin1', begin1 + 'px');
- mydiv.style.setProperty('--begin2', begin2 + 'px');
- aud.paused
- ? (cancelAnimationFrame(raf), mydiv.style.setProperty('--state', 'paused'))
- : (raf = requestAnimationFrame(moving), mydiv.style.setProperty('--state', 'running'));
- };
- </script>
复制代码
|
|