shields.io上提供了各种漂亮的徽标,支持文字、颜色、图标以及各种动静态数据
效果展示
使用详解
1. 各种格式的基本模板
- URL
https://img.shields.io/badge/:badgeContent
- Markdown
![Static Badge](https://img.shields.io/badge/:badgeContent)
- rSt
.. image:: https://img.shields.io/badge/:badgeContent
:alt: Static Badge
- AsciiDoc
image:https://img.shields.io/badge/:badgeContent[Static Badge]
- HTML
2. badgeContent
的基本构成
其中style和logo/自定义图标是组合形式
# 仅文字 标题可省略
https://img.shields.io/badge/{标题}-{内容}-{颜色}
# 添加style
# 值: flat(默认,圆角), flat-square(方角), plastic(塑性/立体), for-the-badge(方角,扁平,字母变大写), social(社交形式)
https://img.shields.io/badge/{标题}-{内容}-{颜色}?style={style}
# 添加logo logo名称在线查找 https://simpleicons.org/
https://img.shields.io/badge/{标题}-{内容}-{颜色}?logo={logo名称}&logoColor={log颜色}
# 自定义图标 图标需要转换为base64编码
https://img.shields.io/badge/{标题}-{内容}-{颜色}?logo={base64编码}
# 动态数据 支持的API查看官方文档 https://shields.io/badges/github-gist-stars
https://img.shields.io/badge/{api}
实例拆解
点击徽章可直接查看url
1. 基本徽标
空格用 %20
表示
https://img.shields.io/badge/Hello%20Weizwz-409eff?style=plastic
2. 带logo徽标
logo在线查找 https://simpleicons.org/
https://img.shields.io/badge/Language-javascript-blue?logo=javascript&logoColor=f7cb4f
3. 自定义图标徽标
推荐 https://www.iconfont.cn/ 下载png格式图标(下载之前可以设置颜色),然后转换base64编码 https://c.runoob.com/front-end/59/
https://img.shields.io/badge/image-circle-4bb2ff?style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAC8VJREFUeF7tnYuR3TYMRclKEldibyWxK/GmEm8qybqSbCpRBrL0IunpQ1IUCRFHM/b6Q4nkBc4AIPXxjuMyBbqu+905J78+TzqRv8ux9VP+72PSfvzz8t/+Hdp9eO+n/3fZfCxe服务器托管网2FucdM45DxDIJb84534b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vDnzTC7fIQ8dr4oIMg6W7yGGmq3pdpfeWxWrnCpAWAaONV9T7T+ccxI53jXNSh0gE0jYddfkKdeOpepK1d7UVALCMvC13qjs6kVuOkyds1pAJnUJO++p1tV9nsqUaimZekCIJrq9PHF0alOqWwIyiSbslyR6pKLTVKdUtwZkEk24I1iRxwcORVIqWcKVn7c5bpFirak5PMorz5ZIjcKhVwEBQnbFg78sq2kqtwWE2kSTG22O5Vbp1Nosbg3IYqWLtEsPM7dYoQqRqwlAiCYhpi7S5tbpVLMRZDqx4bFebqEvwsOjk+bAGGfWTARZ+sMEFAr562BpFozmAVnUJxJRACUfKM2DYQaQBSjy/RLZbGRpOA0WM2CYA2QFlM+8oyuYEnlvwL/e+7fgMxpp2GwNEmKfoU6RqCIpmPzk+F8Bc9HCxCpWqodPinoBxSosPRTOub/udktIqt2PzjMdQbbEMQbLCMVPbU/zHTlvif8HkAOVJ2mY1CxS3N89uoxAuLveH1UCDLNF+llxbwgMQJwwOhHkhHhy6gCMRBb5JVFGjhqRRkCQX+NLD0iZTtpWTgeQDCIe1DIjPL8t9l+mezHjn8ef02cmxj8vf0q3PwUKCurrjPgfvTkUgm6IEW0AAAAASUVORK5CYII=
4. 动态数据徽标
支持的API(包括 GitHub, GitLab, Twitter, YouTube 等)查看官方文档 https://shields.io/badges/github-gist-stars
https://img.shields.io/github/stars/weizwz/hexo-butterfly-recommend?style=social
各个语言/框架/包的版本 https://shields.io/badges/mozilla-add-on-version
https://img.shields.io/npm/v/hexo-butterfly-recommend?color=409eff
数据统计 https://shields.io/badges/npm-package-minimized-gzipped-size-select-exports
https://img.shields.io/github/languages/code-size/weizwz/fun-animation?label=fun-animation%20code%20size
各个语言/框架/包的license https://shields.io/badges/aur-license
https://img.shields.io/aur/license/android-studio?logo=android-studio
下载量(包括浏览器插件、Eclipse应用市场、GitHub发布下载、npm包等) https://shields.io/badges/mozilla-add-on-downloads
https://img.shields.io/chrome-web-store/users/dhdgffkkebhmkfjojejmpbldmpobfkfo?label=%E7%AF%A1%E6%94%B9%E7%8C%B4
其他更多动态API请查看官方文档 https://shields.io/
实际应用
1. GitHub个人介绍
GitHub下新建同名(和你GitHub的ID同名,比如我的 https://github.com/weizwz/weizwz )项目,然后编辑 README.md
保存即可,刷新到你的主页就会自动展示README文档
部分代码展示,完整代码请查看 GitHub-weizwz
# >_ Hello, Friend!
[![Portfolio](https://img.shields.io/website?down_color=lightgrey&down_message=offline&logo=%40thehackingsage&up_color=blue&up_message=portfolio&url=https%3A%2F%2Fweizwz.github.io)](https://weizwz.github.io)
[![Github](https://img.shields.io/github/followers/weizwz?style=social)](https://github.com/weizwz/)
2. GitHub项目徽章
在项目的 README.md
里加入下载量/收藏量/依赖库等徽章
部分代码展示,完整代码请查看 GitHub-vue
3. 博客页脚
1. hexo博客
基于hexo-theme-butterfly
主题,查看 Butterfly文档
在 custom_text
字段里加入以下内容(省去了主题butterfly和腾讯云,因为自定义图标太长,直接代码不显示了,请自行添加):
custom_text:
自定义css如下:
.footer_custom_text {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.footer_custom_text > a {
display: flex;
align-items: center;
margin-top: .5rem;
margin-right: .5rem;
}
2. 博客园页脚
基于主题 CodingLife
,基本操作可查看我之前博客 博客园主题修改分享 – 基础篇
博客后台
-> 设置
-> 页面定制CSS代码
,将下列代码贴入:
/* 页脚 */
#footer {
background: none;
display: flex;
justify-content: center;
color: #333;
flex-wrap: wrap;
}
#poweredby {
width: 100%;
margin-top: .5rem;
margin-left: 0;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
#poweredby > a {
margin-right: .5rem;
}
博客后台
-> 设置
-> 页脚HTML代码
,将下列代码贴入:
function setBlogFooter() {
const $badges = `
`;
const parentDiv = document.querySelector("#poweredby");
parentDiv.innerHTML = $badges;
}
window.addEventListener('load', setBlogFooter, false);
然后保存即可。
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net