最重要的决定——学习黑黑夏商周效果
<style>#papa { left: -242px;top:120px; padding: 0; width: 1080px; height: 607px; background: #eee url('https://pic.imgdb.cn/item/62c69e57f54cd3f9378ac412.jpg') no-repeat center/cover; box-shadow: 4px 4px 30px #000; border-radius: 6px; position: relative; }
#papa input { border: none; outline: none; opacity: .75; cursor: pointer; }
#papa p { margin: 0; padding: 0; }
#playbox { position: absolute; left: 390px; bottom: 10px; padding: 10px; font: normal 1em sans-serif; color: tomato; text-shadow: 1px 1px 1px #000; background: transparent; border-radius: 8px; overflow: hidden; box-shadow: 1px 1px 2px rgba(0,0,0,.15); z-index: 100; }
#playbox::before { position: absolute; content: ''; margin: -20px; left: 0; top: 0; right: 0; bottom: 0;
background: rgba(255,255,255,.45); filter: blur(2px); z-index: -1; }
#btnplay { width: 30px; height: 30px; border-radius: 50%; }
#btnplay:hover { background: #aaa; color: #ff0000; }
#stage { position: absolute; left: 260px; top: 93px; width: 490px; height: 350px; padding: 0; margin: 0;-webkit-clip-path: ellipse(50% 50% at 50% 50%); }
.piece {
position: absolute;
padding: 0;
margin: 0;
border:1px solid transparent;
}
@keyframes in {
80% { transform: scale(1) rotate(0); opacity: 1; }
100% { transform: scale(0) rotate(-360deg); opacity: 0; }
}
@keyframes out {
85% { transform: scale(1) rotate(0); opacity: 1; }
100% { transform: scale(0) rotate(360deg); opacity: 0; }
}
</style>
<div id="papa">
<div id="stage"></div>
<div id="playbox">
<p id="geci" style="font-size: 1.2em">LRC Loading ... </p>
<p style="display: flex; align-items: center; gap: 4px; margin-top: 10px;">
<input id="btnplay" type="button" value=">" />
<input id="slider" type="range" min="0" max="100" value="0" />
<span id="per">0%</span>
</p>
</div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=479408219.mp3" autoplay="autoplay"
loop="loop"></audio>
</div><br><br><br><br><br><br>
<script>
let picAr = [
'https://pic.imgdb.cn/item/62c69e84f54cd3f9378b02aa.png',
'https://pic.imgdb.cn/item/62c69ebdf54cd3f9378b565e.png',
'https://pic.imgdb.cn/item/62c6a2b5f54cd3f937914304.png',
'https://pic.imgdb.cn/item/62c6a2d6f54cd3f93791717e.png'
];
let lrcAr = [
['0.00','最重要的决定 范玮琪 / 杨超毅'],
['20.00','是走上结婚的殿堂 说声我愿意'],
['60.00','相伴一生 不离不弃'],
['170.00','感谢欣赏']
];
let ww = stage.clientWidth,
hh = stage.clientHeight;
let piecesX = 7,
piecesY = 5,
flag = 1,
idx = 0,
slip = 0;
let pw = ww / piecesX;
let ph = hh / piecesY;
let bgar = new Array;
for(j=0; j<piecesY; j++) {
for(k=0; k<piecesX; k++) {
let piece = document.createElement('span');
piece.className = 'piece';
piece.style.width = pw + 'px'
piece.style.height = ph + 'px';
piece.style.left = k * pw + 'px';
piece.style.top = j * ph + 'px';
bgar.push(k * pw + '|' + j * ph); //记录背景数据
stage.appendChild(piece);
}
}
let pieces = document.querySelectorAll('.piece');
function out_in() {
pieces.forEach((ele,key) => {
let ar = bgar.split('|');
ele.style.background = 'url(' + picAr + ') -' + ar+ 'px' + ' -' + ar + 'px no-repeat';
flag == 1 ? (ele.style.animation = 'out 8s 1s', flag = 0) : (ele.style.animation = 'in 8s 1s',
flag = 1);
});
idx ++;
if(idx > picAr.length - 1) idx = 0;
setTimeout(out_in,9000);
}
slider.onmousedown = () => aud.pause();
slider.onchange = () => { aud.currentTime = slider.value * aud.duration / 100; aud.play(); }
btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
aud.addEventListener('playing', () => btnplay.value = '||');
aud.addEventListener('pause', () => btnplay.value = '>');
aud.addEventListener('timeupdate', () => {
let prog = 100 * aud.currentTime / aud.duration;
slider.value = prog;
per.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);
for(j=0; j<lrcAr.length; j++){
if(aud.currentTime >= lrcAr - slip){
geci.innerHTML = lrcAr;
}
}
});
let toMin = (sec) => {
if(!sec) return '0:00';
sec = parseInt(sec);
return parseInt(sec / 60) + ':' + parseFloat(sec % 60).toString().padStart(2,'0');
}
out_in();
</script> 好,能做成椭圆,这个至少能领会 overflow 的作用 好好学习天天向上{:4_173:} 影太厉害啊 也是高手! 红影好制作,晚上好{:4_187:}很有创意, 歌美图靓!真棒!
{:4_204:}{:4_199:} 马黑黑 发表于 2022-7-7 21:24
好,能做成椭圆,这个至少能领会 overflow 的作用
看了代码,是用 -webkit-clip-path 切割手术的{:4_170:} 当新娘子了 马黑黑 发表于 2022-7-7 21:24
好,能做成椭圆,这个至少能领会 overflow 的作用
方的太占地方了,这个背景的空间太小了{:4_173:} 醉美水芙蓉 发表于 2022-7-7 21:29
红影美女厉害!懂得如何改变代码利用代码!
水芙蓉谬赞了,我就是瞎玩,跟大家没法比的{:4_173:} 四海八荒 发表于 2022-7-7 21:42
好好学习天天向上
这个帖子明明是讲结婚的,四海咋看出学习了{:4_173:} 绿叶清舟 发表于 2022-7-7 21:53
影太厉害啊
哪里,还是清舟的那个同花顺更好玩{:4_189:} 亚伦影音工作室 发表于 2022-7-7 23:02
也是高手!
亚伦老师谬赞了,影子只是跟在后面学着玩的{:4_173:} 大猫咪 发表于 2022-7-7 23:08
红影好制作,晚上好很有创意, 歌美图靓!真棒!
猫猫来了,好久不见,看到你真的很开心{:4_171:} 马黑黑 发表于 2022-7-8 06:42
看了代码,是用 -webkit-clip-path 切割手术的
本来是想着切的,后来索性把图图做成椭圆了,然后,这句忘了删了{:4_173:} 加林森 发表于 2022-7-8 09:09
当新娘子了
不是,这首歌是说人生最重要的决定是结婚的决定{:4_173:} 红影 发表于 2022-7-8 16:09
不是,这首歌是说人生最重要的决定是结婚的决定
很重要的事情 椭圆的拼图好漂亮。 红影 发表于 2022-7-8 16:09
本来是想着切的,后来索性把图图做成椭圆了,然后,这句忘了删了
也好