准备工作
- 两个视频,一个白天显示一个晚上显示
- zibll主题设置里面的自定义代码
开始
自定义js代码如下
const currentDate = new Date();
const currentHour = currentDate.getHours();
let videoUrl = '';
if (currentHour >= 8 && currentHour < 20) {
videoUrl = 'https://127.0.0.1/zpc.mp4';
} else {
videoUrl = 'https://127.0.0.1/pc.mp4';
}
const video = document.createElement('video');
video.src = videoUrl;
video.autoplay = true;
video.muted = true;
video.loop = true;
video.style.position = 'fixed';
video.style.top = '50%';
video.style.left = '50%';
video.style.minWidth = '100%';
video.style.minHeight = '100%';
video.style.width = 'auto';
video.style.height = 'auto';
video.style.zIndex = '-100';
video.style.transform = 'translateX(-50%) translateY(-50%)';
document.body.appendChild(video);
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容