红影 发表于 2022-11-20 13:28

往日时光10#(学习黑黑图片按钮+progress封装效果)

<style>
#papa {
      margin: 100px 0 0 calc(50% - 681px);
      width: 1200px;
      height: 640px;
      background: #666 url('https://pic.imgdb.cn/item/6378f53716f2c2beb1cf0fc7.jpg') no-repeat center/cover;
      box-shadow: 3px 3px 20px #000;
      display: grid;
      place-items: center;
      position: relative;
}
#papa::before {
      content: '';
      position: absolute;
      width: 100%;
      height: 100%;
        opacity: .75;
      background: url('https://pic.imgdb.cn/item/62357b1e5baa1a80abd5d64a.gif');
}
#pic {
      position: absolute;
      left: 480px;
      bottom: 120px;
}
.vid { position: absolute; right:40px; top: 40px; width: 400px; height: 200px; object-fit: cover; opacity: .4; clip-path: circle(90% at bottom) ;mix-blend-mode: screen;}
.numClock {
        margin: auto;top:60px; right:110px;
        width: 10em;
        height: 10em;
        background: rgba(240, 248, 255, .6);
        border: 0.6em solid #2f4f4f;
        border-radius: 50%;
        position: absolute;
}
.numClock::before {
        content: "HUACHAO";
        position: absolute;
        width: 100%;
        font-size: 0.75em;
        text-align: center;
        top: 70%;
}
.numBox {
        position: absolute;
        width: 0.75em;
        height: 0.75em;
        font-family: 'Microsoft Yahei', Sans-Seri;
        font-size: 0.75em;
        left: calc(50% - 0.375em);
        top: calc(50% - 0.375em);
        background: transparent;
        text-align:center;
}
.numBox span { display: inline-block; }
.hHand,.mHand,.sHand { position: absolute; width: 100%; height: 100%; background: transparent;}
.hr-hand, .min-hand,.sec-hand {
        position: absolute;
        bottom: 50%;
        transform-origin: 50% 100%;
}
.hr-hand {
        background: #2f4f4f;
        width: 0.2em;
        height: 30%;
        left: calc(50% - 0.1em);
        animation: tRun 43200s linear infinite;
}
.hr-hand::after {
        content: "";
        position: absolute;
        width: 0; height: 0;
        border: 0.25em solid;
        border-color: transparent transparent #2f4f4f transparent;
        right: -0.15em;
        bottom: 100%;
}
.min-hand {
        background: #2f4f4f;
        width: 0.15em;
        height: 42%;
        left: calc(50% - 0.075em);
        animation: tRun 3600s linear infinite;
}
.sec-hand {
        background: #d00;
        width: 0.1em;
        height: 48%;
        left: calc(50% - 0.05em);
        border-radius: 60% 60% 20% 20%;
        animation: tRun 60s linear infinite;
}
.sec-hand::before {
        content: "";
        position: absolute;
        bottom: -0.15em;
        left: -0.15em;
        width: 0.4em;
        height: 0.4em;
        border-radius: 50%;
        background: red;
}
@keyframes tRun { to { transform: rotate(1turn);} }
</style>

<div id="papa">
<video class="vid" src="https://img.tukuppt.com/video_show/2402760/00/01/76/5b49bc6c937da.mp4" autoplay="autoplay" loop="loop" muted="muted"></video>
<img id="pic" src="https://pic.imgdb.cn/item/62ca5956f54cd3f937df455e.gif" alt="" />
<div class="numClock">
        <div class="hHand">
                <div class="hr-hand"></div>
        </div>
        <div class="mHand">
                <div class="min-hand"></div>
        </div>
        <div class="sHand">
                <div class="sec-hand"></div>
        </div>
</div>
</div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1947086494.mp3" loop autoplay></audio>

<script>
var now = new Date();
var        hr = now.getHours() > 12 ? now.getHours() - 12 : now.getHours(),
        min = now.getMinutes(),
        sec = now.getSeconds(),
        msec = now.getMilliseconds();
var        hDeg = hr * 30 + (min * 6 / 12),
        mDeg = min * 6 + (sec * 6 / 60),
        sDeg = sec * 6 + (msec * 0.36 / 1000);

addNum();
godPush("hHand", hDeg);
godPush("mHand", mDeg);
godPush("sHand", sDeg);

function godPush(ele, deg) {
        document.querySelector("." + ele).style.transform = "rotate(" + deg + "deg)";
}
function addNum() {
        var nStr = "";
        for(j=0;j<12;j++) {
                nStr += "<div class='numBox' style='transform: rotate(" + j*30 + "deg) translateY(-5.8em);'><span style='transform: rotate(-" + j*30 + "deg);'>" + (j == 0 ? "12" : j) + "</span></div>";
        }
        document.querySelector(".numClock").innerHTML = nStr + document.querySelector(".numClock").innerHTML;
}
(function(mkPlayer) {let defaults = {lrcAr: [],lrc_css: 'top: 10px; left: 50%; transform: translateX(-50%);',player_css: 'bottom: 20px; left: 50%; transform: translateX(-50%);',playerCode: `<style>#mplayer {position: absolute;bottom: 20px;grid-template-columns: auto auto auto;gap: 6px;display: grid;place-items: center;color: var(--color);font: normal 16px sans-serif;z-index: 999;--ww: 260px;--color: hsl(0, 100%, 100%);--btn_img: linear-gradient(teal 0%, tan 100%);--btn_size: 35px;}#btnplay {--state: paused;width: var(--btn_size);height: var(--btn_size);background: var(--btn_img);border-radius: 50%;opacity: .9;cursor: pointer;animation: rot 3s infinite linear;animation-play-state: var(--state);}#prog {width: var(--ww);height: 20px;opacity: .95;cursor: pointer;}#lrc {--motion: cover2;--tt: 2s;--state: paused;--bg: linear-gradient(180deg, hsla(60, 50%, 50%, .45), hsla(80, 70%, 50%, .6), hsla(0, 100%, 50%, .75));position: absolute;left: 20px;top: 10px;font: bold 2.4em sans-serif;color: hsl(0, 10%, 90%);white-space: pre;-webkit-background-clip: text;filter: drop-shadow(1px 1px 2px hsla(0, 0%, 0%, .95));}#lrc::before {position: absolute;content: attr(data-lrc);width: 20%;height: 100%;color: transparent;overflow: hidden;white-space: pre;background: var(--bg);filter: inherit;-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%; } }@keyframes rot { to { transform: rotate(1turn); } }</style><div id="lrc" data-lrc="HCPlayer">HCPlayer</div><div id="mplayer"><span id="btnplay"></span><progress id="prog" max="100"></progress><span id="tmsg">00:00 | 00:00</span></div>`,};let playCode = (user_config) => {let data = Object.assign({}, defaults, user_config);papa.innerHTML += data.playerCode;mplayer.style.cssText += data.player_css;lrc.style.cssText += data.lrc_css;let mKey = 0, mFlag = true;btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();prog.onclick = (e) => aud.currentTime = aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;aud.addEventListener('timeupdate', () => {prog.value = aud.currentTime / aud.duration * 100;tmsg.innerText = `${toMin(aud.currentTime)} | ${toMin(aud.duration)}`;for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime >= data.lrcAr) {cKey = j;if (mKey === j) showLrc(data.lrcAr);else continue;}}});aud.addEventListener('pause', () => mState());aud.addEventListener('play', () => mState());aud.addEventListener('seeked', () => calcKey());let mState = () => aud.paused ? (lrc.style.setProperty('--state','paused'),btnplay.style.setProperty('--state', 'paused')) : (lrc.style.setProperty('--state','running'),btnplay.style.setProperty('--state', 'running'));let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = lrcAr;lrc.dataset.lrc = lrcAr.replace(/<br>/, '\n');lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');mKey += 1;mFlag = !mFlag;};let calcKey = () => {for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime <= data.lrcAr) {mKey = j - 1;break;}}if (mKey < 0) mKey = 0;if (mKey > data.lrcAr.length - 1) mKey = data.lrcAr.length - 1;let time = data.lrcAr - (aud.currentTime - data.lrcAr);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;}};mkPlayer.HCPlayer = playCode;})(this);
let lrcAr = [
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
       
];
HCPlayer({
      lrcAr: lrcAr,
      lrc_css: 'top: 20px; left: 40px; --bg: linear-gradient(90deg, hsla(55,100%,50%,.35),hsla(31,100%,40%,.6)); color: hsla(120,100%,100%,.95)',
      player_css: 'bottom: 20px; left: 360px; --color: hsl(40,100%,50%); --ww: 260px; --btn_size: 40px; --btn_img: url("https://pic.imgdb.cn/item/6378fa9216f2c2beb1e21d92.gif") no-repeat center/cover;',
});
</script>

红影 发表于 2022-11-20 13:29

黑黑封装了播放器真好,不用管播放器的代码了,想加什么就加什么。
想起以前的花潮时钟,特别喜欢的一个代码,赶紧搬到了这个帖子里。谢谢黑黑的代码{:4_187:}

红影 发表于 2022-11-20 13:30

对了,播放器进度条的覆盖颜色在哪里,就是那个蓝色的部分,想改个颜色,没找到地方@马黑黑{:4_173:}

红影 发表于 2022-11-20 13:33

特别喜欢的一首歌,每次听到,都会想起那些年的校园生活。没什么钱,却是特别欢乐。
想起那会玩麻将,用食堂菜票结算的,输的人这个月就只能点馒头加菜汤了{:4_173:}

红影 发表于 2022-11-20 13:35

还有,他们男生把校门口的小松树偷回宿舍,装扮成圣诞树,还请我们女生去玩,然后他们就被校保卫处请去谈话了{:4_173:}

红影 发表于 2022-11-20 13:36

花潮版封装播放器,花潮版在线时钟,这样的帖子做起来太自豪了。谢谢黑黑{:4_187:}

红影 发表于 2022-11-20 13:37

如今我们变了模样,往日的欢乐却一点也没变……

小辣椒 发表于 2022-11-20 14:19

亲爱的,太棒了,这个效果好美的{:4_178:}

小辣椒 发表于 2022-11-20 14:20

这个钟我都忘记怎么做了{:4_198:}

小辣椒 发表于 2022-11-20 14:22

这个钟我要重新做一次,套用亲爱的的代码,换个黑黑的其他封装播放器,估计明天发{:4_173:}

小辣椒 发表于 2022-11-20 14:23

意境美美的,歌曲也是好怀旧,好听{:4_178:}

红影 发表于 2022-11-20 16:32

小辣椒 发表于 2022-11-20 14:19
亲爱的,太棒了,这个效果好美的

用黑黑的封装播放器,真的太方便了{:4_173:}

红影 发表于 2022-11-20 16:34

小辣椒 发表于 2022-11-20 14:20
这个钟我都忘记怎么做了

还记得黑黑那会做时钟么,做了好多版本,这个应该是最后的版本吧。为了放到帖子里,我把源代码缩小了一些。原来大的那个还要好看{:4_173:}

红影 发表于 2022-11-20 16:35

小辣椒 发表于 2022-11-20 14:22
这个钟我要重新做一次,套用亲爱的的代码,换个黑黑的其他封装播放器,估计明天发

好呀,黑黑封装了十一个播放器呢,我才试了2个,还有好多个没做呢{:4_173:}
最好咱俩合起来把11个全都做一遍。

红影 发表于 2022-11-20 16:36

小辣椒 发表于 2022-11-20 14:23
意境美美的,歌曲也是好怀旧,好听

这首歌倒是一直都喜欢,背景图一般,找不到好看的{:4_173:}

醉美水芙蓉 发表于 2022-11-20 17:01

红影 发表于 2022-11-20 17:36

醉美水芙蓉 发表于 2022-11-20 17:01
欣赏红影美女佳作!播放器是变色的漂亮!

找了个小动图,看看大小正好就用上去了。谢谢水芙蓉美女鼓励{:4_187:}

马黑黑 发表于 2022-11-20 18:04

这是真正的桥段{:4_170:}

马黑黑 发表于 2022-11-20 18:06

红影 发表于 2022-11-20 13:30
对了,播放器进度条的覆盖颜色在哪里,就是那个蓝色的部分,想改个颜色,没找到地方@马黑黑

meter 和 progress标签进度条都木有覆盖颜色,使用的是标签默认的颜色。将来会封装基于 div 或 span 进度条的播放器插件,你就可以定义 track 和 prog 颜色了

红影 发表于 2022-11-20 18:43

马黑黑 发表于 2022-11-20 18:06
meter 和 progress标签进度条都木有覆盖颜色,使用的是标签默认的颜色。将来会封装基于 div 或 span 进度 ...

原来是这样,怪不得我跑到封装里翻了又翻也没找到,还以为查找不仔细{:4_173:}
页: [1] 2 3 4 5 6 7 8
查看完整版本: 往日时光10#(学习黑黑图片按钮+progress封装效果)