生活闪亮时
本帖最后由 醉美水芙蓉 于 2023-5-26 21:04 编辑 <br /><br /><style>#papa {
margin: 80px 0 0 calc(50% - 681px);
width: 1200px;
height: 700px;
background: tan;
box-shadow: 0 0 10px gray;
position: relative;
--state: paused;
}
css-doodle { position: absolute; overflow: hidden;}
.vid { position: absolute; width: 1200px; height: 700px;object-fit: cover; opacity: 1; }
</style>
<div id="papa">
<video class="vid" src="https://img-baofun.zhhainiao.com/fs/live/preview_video/d7041da1a9ff9db19f8ca83bdaded1c3_preview.mp4" autoplay="autoplay" loop="loop" muted="muted"></video>
<css-doodle grid="20" id="mplayer">
:doodle {
@size: 1024px 640px;
z-index: 1;
}
@size: @r(4, 8)px;
@place: 390px 360px;
border-radius: 50%;
background: rgba(@m3(@r(222)), @r(.7, 1));
animation: fly @r(6,16)s @r(-6,0)s infinite linear var(--state);
@nth(@size) {
@size: 100px;
@shape: bud 5;
background: rgba(50,50,250,.7);
cursor: pointer;
animation: rot 5s infinite linear var(--state);
}
@keyframes fly {
0% { transform: perspective(800px) rotate(0) translate3d(0, 0, 0); }
100% { transform: perspective(800px) rotate(@p(-720, 720)deg) translate3d(var(--rx), var(--ry), var(--rz)); }
}
@keyframes rot { to { transform: rotate(360deg); } }
--rx: @r(10,50)px; --ry: @r(10,80)px; --rz: @r(20,800)px;
</css-doodle>
<css-doodle id="lrc">
:doodle {
@size: auto 4em;
top: 10px;
left:550px;
--geci: "花潮lrc在线"; --motion: cover2; --tt: 1s;
}
/* 单元格两个伪元素显示lrc歌词 */
display: grid;
place-items: center start;
:before, :after {
content: var(--geci);
color: gray; /* 歌词底色 */
font: bold 2em sans-serif;
text-shadow: 1px 1px 2px #000;
white-space: pre;
}
:after {
position: absolute;
width: 0;
color: darkgreen; /* 同步歌词颜色 */
overflow: hidden;
animation: var(--motion) var(--tt) linear forwards var(--state);
}
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
</css-doodle>
<audio id="aud" src="https://www.qqmc.com/mp3/music277550717.mp3" autoplay loop></audio>
</div>
<script>
(function() {
let script = document.createElement('script');
script.src = 'https://unpkg.com/css-doodle@0.34.9/css-doodle.min.js';
document.head.appendChild(script);
let slip = 0.5, mFlag = true, mKey = 0, clickIdx = 0, progChg = 0, cursors = ['default','pointer','pointer'];
let lrcAr = [
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
];
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 calcKey = () => {for (j = 0;j < lrcAr.length;j++) {if (aud.currentTime <= lrcAr) {mKey = j - 1;break;}}if (mKey < 0) mKey = 0;if (mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;let time = lrcAr - (aud.currentTime - lrcAr);showLrc(time);};
let mState = () => papa.style.setProperty('--state', aud.paused ? 'paused' : 'running');
let showLrc = (time) => {lrc.style.setProperty('--motion', mFlag ? 'cover1' : 'cover2');lrc.style.setProperty('--geci', '"' + lrcAr + '"');lrc.style.setProperty('--tt', time + 's');mKey += 1;mFlag = !mFlag;};
aud.addEventListener('play', mState, false);
aud.addEventListener('pause', mState, false);
aud.addEventListener('seeked', () => calcKey());
aud.addEventListener('timeupdate', () => {for (j = 0; j < lrcAr.length; j++) {if (aud.currentTime - slip >= lrcAr) {cKey = j;if (mKey === j) showLrc(lrcAr);else continue;}}mplayer.style.setProperty('--ttmsg1', `'${toMin(aud.currentTime)}'`);mplayer.style.setProperty('--ttmsg2', `'${toMin(aud.duration)}'`);mplayer.style.setProperty('--prog',`${100 * aud.currentTime / aud.duration}%`);});
mplayer.onclick = () => {if(clickIdx === 1) aud.paused ? aud.play() : aud.pause();if(clickIdx === 2) aud.currentTime = progChg;};
mplayer.onmousemove = (e) => {let size = parseInt(window.getComputedStyle(mplayer).getPropertyValue('--size')), ww = mplayer.offsetWidth, hh = mplayer.offsetHeight;clickIdx = e.offsetY > hh/1.5 ? 2 : (e.offsetX > (ww - size)/2 && e.offsetX < (ww + size)/2 && e.offsetY < hh/1.5 ? 1 : 0);mplayer.style.cursor = cursors;if(clickIdx > 1) progChg = aud.duration * e.offsetX / ww;};
})();
</script>
很不错的效果 马黑黑 发表于 2023-5-25 21:18
很不错的效果
黑黑老师晚上好! 醉美水芙蓉 发表于 2023-5-25 21:19
黑黑老师晚上好!
{:4_191:} 背景图很清新,播放器很精致唯美,问好芙蓉{:4_178:} 千羽 发表于 2023-5-25 21:30
背景图很清新,播放器很精致唯美,问好芙蓉
千羽美女晚上好! 水芙蓉的这个制作好漂亮,美美哒{:4_187:} 漂亮哦,有歌词的{:4_187:} 是不是没设置超出的不显示?感觉电脑的下面的条幅在变化。 红影 发表于 2023-5-25 21:50
水芙蓉的这个制作好漂亮,美美哒
红影美女晚上好! 南无月 发表于 2023-5-25 21:51
漂亮哦,有歌词的
是的,学着加了歌词! 红影 发表于 2023-5-25 21:51
是不是没设置超出的不显示?感觉电脑的下面的条幅在变化。
不懂,可否告知如何加? 美哒哒的作品 一斛珠 发表于 2023-5-25 22:14
美哒哒的作品
谢谢朋友支持! 马黑黑 发表于 2023-5-25 21:18
很不错的效果
红影说电脑的下面的条幅在变化!@马黑黑 老师这是怎么回事? 醉美水芙蓉 发表于 2023-5-25 22:34
红影说电脑的下面的条幅在变化!@马黑黑 老师这是怎么回事?
浏览器版本低的缘故吧。确保水平方向和垂直方向的滚动条不自动发生变化,可以在 :doodle {} 的花括号内加入 overflow: hidden; 一句 醉美水芙蓉 发表于 2023-5-25 22:06
红影美女晚上好!
问好水芙蓉,周末快乐{:4_187:}
页:
[1]