shields.io上提供了各种漂亮的徽标,支持文字、颜色、图标以及各种动静态数据

效果展示

使用详解

1. 各种格式的基本模板

1
https://img.shields.io/badge/:badgeContent
1
![Static Badge](https://img.shields.io/badge/:badgeContent)
1
2
.. image:: https://img.shields.io/badge/:badgeContent
:alt: Static Badge
1
image:https://img.shields.io/badge/:badgeContent[Static Badge]
1
<img alt="Static Badge" src="https://img.shields.io/badge/:badgeContent">

2. badgeContent 的基本构成

其中style和logo/自定义图标是组合形式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 仅文字 标题可省略
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 表示

1
https://img.shields.io/badge/Hello%20Weizwz-409eff?style=plastic

2. 带logo徽标

logo在线查找 https://simpleicons.org/

1
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/

1
https://img.shields.io/badge/image-circle-4bb2ff?style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAC8VJREFUeF7tnYuR3TYMRclKEldibyWxK/GmEm8qybqSbCpRBrL0IunpQ1IUCRFHM/b6Q4nkBc4AIPXxjuMyBbqu+905J78+TzqRv8ux9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Sth38zOyS30ZyptPpudUiyAIU9klyWbSd61SHo3oEAZJ2vDnzTC7fIQ8dr4oIMg6W7yGGmq3pdpfeWxWrnCpAWAaONV9T7T+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

1
https://img.shields.io/github/stars/weizwz/hexo-butterfly-recommend?style=social

各个语言/框架/包的版本 https://shields.io/badges/mozilla-add-on-version

1
https://img.shields.io/npm/v/hexo-butterfly-recommend?color=409eff

数据统计 https://shields.io/badges/npm-package-minimized-gzipped-size-select-exports

1
https://img.shields.io/github/languages/code-size/weizwz/fun-animation?label=fun-animation%20code%20size

各个语言/框架/包的license https://shields.io/badges/aur-license

1
https://img.shields.io/aur/license/android-studio?logo=android-studio

下载量(包括浏览器插件、Eclipse应用市场、GitHub发布下载、npm包等) https://shields.io/badges/mozilla-add-on-downloads

1
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文档
image
部分代码展示,完整代码请查看 GitHub-weizwz

1
2
3
# >_ 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 里加入下载量/收藏量/依赖库等徽章
image

部分代码展示,完整代码请查看 GitHub-vue

1
2
3
4
5
6
7
8
9
10
<p align="center"><a href="https://vuejs.org" target="_blank" rel="noopener noreferrer"><img width="100" src="https://vuejs.org/images/logo.png" alt="Vue logo"></a></p>

<p align="center">
<a href="https://circleci.com/gh/vuejs/vue/tree/dev"><img src="https://img.shields.io/circleci/project/github/vuejs/vue/dev.svg?sanitize=true" alt="Build Status"></a>
<a href="https://codecov.io/github/vuejs/vue?branch=dev"><img src="https://img.shields.io/codecov/c/github/vuejs/vue/dev.svg?sanitize=true" alt="Coverage Status"></a>
<a href="https://npmcharts.com/compare/vue?minimal=true"><img src="https://img.shields.io/npm/dm/vue.svg?sanitize=true" alt="Downloads"></a>
<a href="https://www.npmjs.com/package/vue"><img src="https://img.shields.io/npm/v/vue.svg?sanitize=true" alt="Version"></a>
<a href="https://www.npmjs.com/package/vue"><img src="https://img.shields.io/npm/l/vue.svg?sanitize=true" alt="License"></a>
<a href="https://chat.vuejs.org/"><img src="https://img.shields.io/badge/chat-on%20discord-7289da.svg?sanitize=true" alt="Chat"></a>
</p>

3. 博客页脚

基于hexo-theme-butterfly主题,查看 Butterfly文档
image
custom_text 字段里加入以下内容(省去了主题butterfly和腾讯云,因为自定义图标太长,直接代码不显示了,请自行添加):

1
custom_text: <a target="_blank" href="https://hexo.io/" title="博客框架为Hexo_v7.0.0"><img src="https://img.shields.io/badge/Frame-Hexo-0E83CD?logo=hexo&logoColor=fff"></a><a target="_blank" href="https://github.com/" title="本站项目由Github托管"><img src="https://img.shields.io/badge/Website-Github-d021d6?logo=GitHub"></a><a target="_blank" href="https://www.algolia.com/" title="本站搜索使用Algolia搜索服务"><img src="https://img.shields.io/badge/Search-Algolia-003DFF?logo=Algolia"></a><a target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="本站采用CC BY-NC-SA 4.0国际许可协议进行许可"><img src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?logo=coursera&logoColor=fff"></a>

自定义css如下:

1
2
3
4
5
6
7
8
9
10
11
12
.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;
}