HTML + CSS 实现 GitHub 项目标签、徽章样式


经常会在GitHub上项目介绍的README.md文件中看到许多漂亮的标签,这些标签可以显示version、stars、license等信息
HTML + CSS 实现 GitHub 项目标签、徽章样式_第1张图片
我们可以通过 https://shields.io/ 这个网站在线制作图标,填写label、message、color三个字段,点击Make Badge就可以生成图标,还有其他功能可以自己去体验。
HTML + CSS 实现 GitHub 项目标签、徽章样式_第2张图片
我们也可以通过 HTML + CSS 来实现:

CSS

.github-badge {
	display: inline-block;
	border-radius: 4px;
	text-shadow: none;
	font-size: 12px;
	color: #fff;
	line-height: 15px;
	background-color: #ABBAC3;
  margin-bottom: 5px;
}
.github-badge .badge-subject {
	display: inline-block;
	background-color: #4D4D4D;
	padding: 4px 4px 4px 6px;
	border-top-left-radius: 4px;
	border-bottom-left-radius: 4px;
}
.github-badge .badge-value {
	display: inline-block;
	padding: 4px 6px 4px 4px;
	border-top-right-radius: 4px;
	border-bottom-right-radius: 4px;
}
.github-badge .bg-brightgreen {
	background-color: #4DC820 !important;
}
.github-badge .bg-orange {
	background-color: #FFA500 !important;
}
.github-badge .bg-yellow {
	background-color: #D8B024 !important;
}
.github-badge .bg-blueviolet {
	background-color: #8833D7 !important;
}
.github-badge .bg-pink {
	background-color: #F26BAE !important;
}
.github-badge .bg-red {
	background-color: #e05d44 !important;
}
.github-badge .bg-blue {
	background-color: #007EC6 !important;
}
.github-badge .bg-lightgrey {
	background-color: #9F9F9F !important;
}
.github-badge .bg-grey, .github-badge .bg-gray {
	background-color: #555 !important;
}
.github-badge .bg-lightgrey, .github-badge .bg-lightgray {
	background-color: #9f9f9f !important;
}

HTML

  <div class="github-badge">
    <span class="badge-subject">Poweredspan><span class="badge-value bg-blue">Hexospan>
  div>
  <div class="github-badge">
    <span class="badge-subject">Hostedspan><span class="badge-value bg-brightgreen">GitHubspan>
  div>
  <div class="github-badge">
    <span class="badge-subject">DNRspan><span class="badge-value bg-firebrick">Aliyunspan>
  div>
  <div class="github-badge">
    <span class="badge-subject">CDNspan><span class="badge-value bg-orange">jsDelivrspan>
  div>
  <div class="github-badge">
    <span class="badge-subject">PictureBedspan><span class="badge-value bg-blueviolet">SM.MSspan>
  div>
  <div class="github-badge">
    <span class="badge-subject">Themespan><span class="badge-value bg-blue">Material Xspan>
  div>
  <div class="github-badge">
    <span class="badge-subject"><i class="fa fa-copyright">i>span><span class="badge-value bg-lightgrey">BY-NC-SA 4.0span>
  div>

最终效果

HTML + CSS 实现 GitHub 项目标签、徽章样式_第3张图片
参考资料:CSS - Badge

你可能感兴趣的:(【,Web,前端,】,【,Hexo,博客搭建,】)