724 字
4 分钟
fuwari页脚优化

前言#

本来的fuwari页脚界面实在是分的太开了,想着修改一下样式,就动手了。

虽然现在还是很开。但是起码看上去好看了不少。

对比#

img img

总结#

感觉也没多好看,只是把其他的东西删掉了,看上去简洁了不少。

相关代码#

---
const currentYear = new Date().getFullYear()
---
<footer class="fuwari-compatible-footer">
<div class="footer-row">
<span id="runningtime" class="footer-runtime"></span>
</div>
<div class="footer-row">
<a class="badge-link" href="https://beian.miit.gov.cn/" target="_blank"
onclick="event.preventDefault(); copyAndJump('桂ICP备2025069002号-1', this.href)">
<img src="https://img.shields.io/badge/ICP备-桂ICP备2025069002号--1-blue" alt="ICP备案号">
</a>
<a class="badge-link" href="https://beian.mps.gov.cn/" target="_blank"
onclick="event.preventDefault(); copyAndJump('浙公网安备33080202000712号', this.href)">
<img src="https://img.shields.io/badge/公安备-浙公网安备33080202000712号-green" alt="公安备案号">
</a>
</div>
<div class="footer-row">
<a class="badge-link" href="https://icp.gov.moe/?keyword=20257776" target="_blank">
<img src="https://img.shields.io/badge/萌ICP备-20257776号-ff69b4" alt="萌ICP备案号">
</a>
<a class="badge-link" href="https://icp.wudu.ltd/id.php?keyword=00000000" target="_blank">
<img src="https://img.shields.io/badge/雾备-00000000号-7ed6df" alt="雾备备案号">
</a>
<a class="badge-link" href="https://icp.redcha.cn/beian/ICP-2025080132.html" target="_blank">
<img src="https://img.shields.io/badge/茶ICP备-2025080132号-7474e1" alt="茶ICP备案号">
</a>
</div>
<div class="footer-row powered-by">
<span>本网站由</span>
<a href="https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral" target="_blank" rel="noopener">
<img src="https://cdn.jsdelivr.net/gh/sjhxlll/fuwari-img@master/upyun_logos/%E5%8F%88%E6%8B%8D%E4%BA%91_logo2.png" alt="又拍云 Upyun" width="59" height="30" style="vertical-align:middle;" />
</a>
<span>提供 CDN 加速</span>
</div>
</footer>
<script is:inline>
function runtime() {
// 记得把这里的日期改成你自己网站的上线日期哦!
const t = new Date("07/21/2025 16:58:58"), n = new Date, s = n - t;
const o = Math.floor(s / 1e3 / 86400), i = Math.floor(s / 1e3 % 86400 / 3600), a = Math.floor(s / 1e3 % 3600 / 60), r = Math.floor(s / 1e3 % 60);
const el = document.getElementById("runningtime");
if (el) el.innerHTML = `⭐本站已运行: ${o}天${i}小时${a}分${r}秒 ☁️`;
}
setInterval(runtime, 1000);
function copyAndJump(text, url) {
navigator.clipboard.writeText(text).then(() => {
if (window.confirm('备案号已复制:' + text + '\n是否前往备案网站?')) {
window.open(url, '_blank');
}
});
}
</script>
<style>
.fuwari-compatible-footer {
width: 100%;
padding: 2rem 1rem; /* 增加上下边距,看起来更舒服 */
margin-top: 5rem; /* 和上面的内容拉开距离 */
border-top: 1px solid var(--color-border); /* 使用主题的边框颜色,增加一条分割线 */
/* 2. 颜色适配:全部使用fuwari主题的CSS变量 */
background: transparent; /* 背景设为透明,它会自动使用页面的背景色 */
color: var(--color-text-sub); /* 使用主题的次要文字颜色 */
/* 3. 内容对齐 */
display: flex;
flex-direction: column;
align-items: center;
gap: 0.8rem; /* 调整行间距 */
font-size: 0.875rem; /* 调整字体大小,更精致 */
transition: all 0.3s; /* 保留一个平滑的过渡效果 */
}
.footer-row {
display: flex;
justify-content: center;
align-items: center;
gap: 12px;
flex-wrap: wrap; /* 允许换行,适配移动端 */
width: 100%;
}
.fuwari-compatible-footer .badge-link img {
transition: all 0.25s ease-in-out;
vertical-align: middle;
height: 22px; /* 保持徽章大小 */
border-radius: 4px; /* 加一点小圆角,更可爱 */
}
.fuwari-compatible-footer .badge-link:hover img {
transform: translateY(-2px) scale(1.05); /* 鼠标悬浮时,稍微放大并上移一点点 */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.powered-by {
display: flex;
align-items: center;
gap: 5px;
}
/* 链接颜色也用主题的强调色 */
.powered-by a {
color: var(--color-accent); /* 使用主题的强调色 */
text-decoration: none;
font-weight: bold;
opacity: 0.8;
}
.powered-by a:hover {
opacity: 1; /* 鼠标悬浮时不透明 */
}
.footer-runtime {
font-weight: 500;
white-space: nowrap;
text-align: center;
}
/* 不再需要单独为暗黑模式写样式了,因为CSS变量会自动切换!*/
</style>
fuwari页脚优化
https://blog.xomoe.cn/posts/2025-09-05/footer-better/
作者
发布于
2025-09-05
许可协议
CC BY-NC-SA 4.0
页面浏览量:0

💡 评论需审核