Bootstrap 3 Glyphicons CDN


82

请注意!

此合并请求合并,Bootstrap图标又回来了


在过去的几周内反复进行此操作之后,我决定将Glyphicons图标字体恢复为主仓库。考虑到UI中普遍使用的图标,对于大多数人来说,不将它们(或其他一些图标字体)与CSS和JS包含在同一位置可能是不利的。

此更新附带以下内容:

  • 恢复文档(在“组件”页面上)
  • 新变量,@icon-font-path以及@icon-font-name,可灵活添加和删除图标字体
  • 升级到最新的Glyphicons(添加40个新图标)
  • 从CSS页面中删除旧的Glyphicons提及

将来,我们将致力于改进图标字体的自定义设置,以便更轻松地交换字体库(这是原始删除字体的全部动机)。


新版Twitter Bootstrap Glyphicons的CDN网址是哪个?

他们从Bootstrap 3中移到了一个单独的存储库中,但是我没有找到任何CDN。

从官方文档中:

随着Bootstrap 3的发布,图标已被移至单独的存储库。这样可以使主要项目保持精简,使人们更容易交换图标库,并使Glyphicons图标字体更容易为Bootstrap之外的更多人使用。

官方网站上他们没有提供图标的CDN网址。

在哪里可以找到它?我不想下载存储库并将其包含到我的项目中。


1
Boostrap CDN的Bootswatch主题CSS文件不包含字形图标,对吗?文件:netdna.bootstrapcdn.com/bootswatch/3.0.0/amelia/...
trante

Answers:


154

随着Bootstrap 3的最新发行版以及glyphicons被合并回Bootstrap主仓库中,Bootstrap CDN现在正在提供包括Glyphicons在内的完整Bootstrap 3.0 css。您需要包括Bootstrap css参考:Glyphicons及其依赖项位于CDN站点上的相对路径上,并在中进行了引用bootstrap.min.css

在html中:

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">

在CSS中:

 @import url("//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css");

这是一个工作示例

请注意,您必须使用.glyphicon类而不是.icon

例:

<span class="glyphicon glyphicon-heart"></span>

还要注意,您仍然需要包括bootstrap.min.jsBootstrap JavaScript组件的使用,有关URL ,请参见Bootstrap CDN


如果要单独使用Glyphicons,则可以通过直接引用Bootstrap CDN上的Glyphicons css来实现。

在html中:

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">

在CSS中:

@import url("//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css");

由于css文件已经包含所有需要的Glyphicons依赖项(位于Bootstrap CDN站点的相对路径中),因此添加css文件就是开始使用Glyphicons的全部工作。

这是不带Bootstrap的Glyphicons的工作演示


嗯,有趣。似乎是正确的答案,但是切换到该URL时不会显示图标。很棒的字体效果很好。带有图标规则的CSS文件已加载。我还需要什么吗?图片?
尼卡比曹

@JohnツCSS文件中的第一个类是@ font-face类,它导入所有需要的字体文件(包括一个svg图像文件),这些文件位于Bootstrap CDN站点上的相对路径中。因此,您无需任何其他操作。
edsioufi 2013年

感谢您的演示。我稍后再看,很快我的应用程序工作就会接受这个答案。请编辑您的答案,并将内容从注释添加到ID。谢谢!
尼卡比曹

1
非常感谢。我刚刚看到它.icon不再使用了。
尼卡比曹

并且在解决此问题之前不要使用自定义版本的字体:github.com/twbs/bootstrap/issues/9925
OZ_

27

一种替代方法是对图标使用Font-Awesome

包括超赞字体

在CDNJS上打开Font-Awesome并复制最新版本的CSS url:

<link rel="stylesheet" href="<url>">

或在CSS中

@import url("<url>");

例如(请注意,版本将更改):

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">

用法:

<i class="fa fa-bed"></i>

它包含很多图标


经过数小时的尝试使图标正常工作之后,链接到超赞的CDN解决了我的问题。谢谢。
令人信服的2014年

@Eenvincible不要忘记使用最新版本。我的答案中的链接有些过时了。
尼卡比曹

网址已更改:<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
nimrod

字体超赞的文件包含更多图标。真好
dudewad 2015年

不包括bootstrap的字形,而是依赖fa会给依赖bootstrap的库带来问题。例如Angular-ui-select将丢失一些图标
Robin-Hoodie

3

尽管Bootstrap CDN将字形恢复到bootstrap.min.css,但是Bootstrap CDN的Bootswatch css文件不包含字形。

例如Amelia主题:http : //bootswatch.com/amelia/

默认的Amelia在此文件中包含字形符号:http ://bootswatch.com/amelia/bootstrap.min.css

但是Bootstrap CDN的css文件不包含字形图标:http://netdna.bootstrapcdn.com/bootswatch/3.0.0/amelia/bootstrap.min.css

因此,如@edsioufi所述,如果您使用引导CDN中的Bootswatch文件,则应该包括glphicons css。文件:http//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css


引导程序中的定制程序有时还会生成无效的字体文件。单独下载字体文件有助于我找回图标。有时是引导程序包错误。
Clain Dsilva

trante:您的信息不正确。如果检查链接,您会发现引导主题的Bootstrap CDN确实包含字形图标。
Michael Moriarty

1

如果只希望有glyphicons图标而没有任何其他CSS,则可以创建一个CSS文件并将代码放在下面,并将其包含在主CSS文件中。

我必须创建这个额外的文件,因为下面的链接也弄乱了我的网站样式。

//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css

我直接创建了一个CSS文件,而不是直接使用它 bootstrap-glyphicons.css

@font-face{font-family:'Glyphicons Halflings';src:url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/fonts/glyphicons-halflings-regular.eot');src:url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/fonts/glyphicons-halflings-regular.woff') format('woff'),url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/fonts/glyphicons-halflings-regular.ttf') format('truetype'),url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';font-style:normal;font-weight:normal;line-height:1;-webkit-font-smoothing:antialiased;}
.glyphicon-asterisk:before{content:"\2a";}
.glyphicon-plus:before{content:"\2b";}
.glyphicon-euro:before{content:"\20ac";}
.glyphicon-minus:before{content:"\2212";}
.glyphicon-cloud:before{content:"\2601";}
.glyphicon-envelope:before{content:"\2709";}
.glyphicon-pencil:before{content:"\270f";}
.glyphicon-glass:before{content:"\e001";}
.glyphicon-music:before{content:"\e002";}
.glyphicon-search:before{content:"\e003";}
.glyphicon-heart:before{content:"\e005";}
.glyphicon-star:before{content:"\e006";}
.glyphicon-star-empty:before{content:"\e007";}
.glyphicon-user:before{content:"\e008";}
.glyphicon-film:before{content:"\e009";}
.glyphicon-th-large:before{content:"\e010";}
.glyphicon-th:before{content:"\e011";}
.glyphicon-th-list:before{content:"\e012";}
.glyphicon-ok:before{content:"\e013";}
.glyphicon-remove:before{content:"\e014";}
.glyphicon-zoom-in:before{content:"\e015";}
.glyphicon-zoom-out:before{content:"\e016";}
.glyphicon-off:before{content:"\e017";}
.glyphicon-signal:before{content:"\e018";}
.glyphicon-cog:before{content:"\e019";}
.glyphicon-trash:before{content:"\e020";}
.glyphicon-home:before{content:"\e021";}
.glyphicon-file:before{content:"\e022";}
.glyphicon-time:before{content:"\e023";}
.glyphicon-road:before{content:"\e024";}
.glyphicon-download-alt:before{content:"\e025";}
.glyphicon-download:before{content:"\e026";}
.glyphicon-upload:before{content:"\e027";}
.glyphicon-inbox:before{content:"\e028";}
.glyphicon-play-circle:before{content:"\e029";}
.glyphicon-repeat:before{content:"\e030";}
.glyphicon-refresh:before{content:"\e031";}
.glyphicon-list-alt:before{content:"\e032";}
.glyphicon-flag:before{content:"\e034";}
.glyphicon-headphones:before{content:"\e035";}
.glyphicon-volume-off:before{content:"\e036";}
.glyphicon-volume-down:before{content:"\e037";}
.glyphicon-volume-up:before{content:"\e038";}
.glyphicon-qrcode:before{content:"\e039";}
.glyphicon-barcode:before{content:"\e040";}
.glyphicon-tag:before{content:"\e041";}
.glyphicon-tags:before{content:"\e042";}
.glyphicon-book:before{content:"\e043";}
.glyphicon-print:before{content:"\e045";}
.glyphicon-font:before{content:"\e047";}
.glyphicon-bold:before{content:"\e048";}
.glyphicon-italic:before{content:"\e049";}
.glyphicon-text-height:before{content:"\e050";}
.glyphicon-text-width:before{content:"\e051";}
.glyphicon-align-left:before{content:"\e052";}
.glyphicon-align-center:before{content:"\e053";}
.glyphicon-align-right:before{content:"\e054";}
.glyphicon-align-justify:before{content:"\e055";}
.glyphicon-list:before{content:"\e056";}
.glyphicon-indent-left:before{content:"\e057";}
.glyphicon-indent-right:before{content:"\e058";}
.glyphicon-facetime-video:before{content:"\e059";}
.glyphicon-picture:before{content:"\e060";}
.glyphicon-map-marker:before{content:"\e062";}
.glyphicon-adjust:before{content:"\e063";}
.glyphicon-tint:before{content:"\e064";}
.glyphicon-edit:before{content:"\e065";}
.glyphicon-share:before{content:"\e066";}
.glyphicon-check:before{content:"\e067";}
.glyphicon-move:before{content:"\e068";}
.glyphicon-step-backward:before{content:"\e069";}
.glyphicon-fast-backward:before{content:"\e070";}
.glyphicon-backward:before{content:"\e071";}
.glyphicon-play:before{content:"\e072";}
.glyphicon-pause:before{content:"\e073";}
.glyphicon-stop:before{content:"\e074";}
.glyphicon-forward:before{content:"\e075";}
.glyphicon-fast-forward:before{content:"\e076";}
.glyphicon-step-forward:before{content:"\e077";}
.glyphicon-eject:before{content:"\e078";}
.glyphicon-chevron-left:before{content:"\e079";}
.glyphicon-chevron-right:before{content:"\e080";}
.glyphicon-plus-sign:before{content:"\e081";}
.glyphicon-minus-sign:before{content:"\e082";}
.glyphicon-remove-sign:before{content:"\e083";}
.glyphicon-ok-sign:before{content:"\e084";}
.glyphicon-question-sign:before{content:"\e085";}
.glyphicon-info-sign:before{content:"\e086";}
.glyphicon-screenshot:before{content:"\e087";}
.glyphicon-remove-circle:before{content:"\e088";}
.glyphicon-ok-circle:before{content:"\e089";}
.glyphicon-ban-circle:before{content:"\e090";}
.glyphicon-arrow-left:before{content:"\e091";}
.glyphicon-arrow-right:before{content:"\e092";}
.glyphicon-arrow-up:before{content:"\e093";}
.glyphicon-arrow-down:before{content:"\e094";}
.glyphicon-share-alt:before{content:"\e095";}
.glyphicon-resize-full:before{content:"\e096";}
.glyphicon-resize-small:before{content:"\e097";}
.glyphicon-exclamation-sign:before{content:"\e101";}
.glyphicon-gift:before{content:"\e102";}
.glyphicon-leaf:before{content:"\e103";}
.glyphicon-eye-open:before{content:"\e105";}
.glyphicon-eye-close:before{content:"\e106";}
.glyphicon-warning-sign:before{content:"\e107";}
.glyphicon-plane:before{content:"\e108";}
.glyphicon-random:before{content:"\e110";}
.glyphicon-comment:before{content:"\e111";}
.glyphicon-magnet:before{content:"\e112";}
.glyphicon-chevron-up:before{content:"\e113";}
.glyphicon-chevron-down:before{content:"\e114";}
.glyphicon-retweet:before{content:"\e115";}
.glyphicon-shopping-cart:before{content:"\e116";}
.glyphicon-folder-close:before{content:"\e117";}
.glyphicon-folder-open:before{content:"\e118";}
.glyphicon-resize-vertical:before{content:"\e119";}
.glyphicon-resize-horizontal:before{content:"\e120";}
.glyphicon-hdd:before{content:"\e121";}
.glyphicon-bullhorn:before{content:"\e122";}
.glyphicon-certificate:before{content:"\e124";}
.glyphicon-thumbs-up:before{content:"\e125";}
.glyphicon-thumbs-down:before{content:"\e126";}
.glyphicon-hand-right:before{content:"\e127";}
.glyphicon-hand-left:before{content:"\e128";}
.glyphicon-hand-up:before{content:"\e129";}
.glyphicon-hand-down:before{content:"\e130";}
.glyphicon-circle-arrow-right:before{content:"\e131";}
.glyphicon-circle-arrow-left:before{content:"\e132";}
.glyphicon-circle-arrow-up:before{content:"\e133";}
.glyphicon-circle-arrow-down:before{content:"\e134";}
.glyphicon-globe:before{content:"\e135";}
.glyphicon-tasks:before{content:"\e137";}
.glyphicon-filter:before{content:"\e138";}
.glyphicon-fullscreen:before{content:"\e140";}
.glyphicon-dashboard:before{content:"\e141";}
.glyphicon-heart-empty:before{content:"\e143";}
.glyphicon-link:before{content:"\e144";}
.glyphicon-phone:before{content:"\e145";}
.glyphicon-usd:before{content:"\e148";}
.glyphicon-gbp:before{content:"\e149";}
.glyphicon-sort:before{content:"\e150";}
.glyphicon-sort-by-alphabet:before{content:"\e151";}
.glyphicon-sort-by-alphabet-alt:before{content:"\e152";}
.glyphicon-sort-by-order:before{content:"\e153";}
.glyphicon-sort-by-order-alt:before{content:"\e154";}
.glyphicon-sort-by-attributes:before{content:"\e155";}
.glyphicon-sort-by-attributes-alt:before{content:"\e156";}
.glyphicon-unchecked:before{content:"\e157";}
.glyphicon-expand:before{content:"\e158";}
.glyphicon-collapse-down:before{content:"\e159";}
.glyphicon-collapse-up:before{content:"\e160";}
.glyphicon-log-in:before{content:"\e161";}
.glyphicon-flash:before{content:"\e162";}
.glyphicon-log-out:before{content:"\e163";}
.glyphicon-new-window:before{content:"\e164";}
.glyphicon-record:before{content:"\e165";}
.glyphicon-save:before{content:"\e166";}
.glyphicon-open:before{content:"\e167";}
.glyphicon-saved:before{content:"\e168";}
.glyphicon-import:before{content:"\e169";}
.glyphicon-export:before{content:"\e170";}
.glyphicon-send:before{content:"\e171";}
.glyphicon-floppy-disk:before{content:"\e172";}
.glyphicon-floppy-saved:before{content:"\e173";}
.glyphicon-floppy-remove:before{content:"\e174";}
.glyphicon-floppy-save:before{content:"\e175";}
.glyphicon-floppy-open:before{content:"\e176";}
.glyphicon-credit-card:before{content:"\e177";}
.glyphicon-transfer:before{content:"\e178";}
.glyphicon-cutlery:before{content:"\e179";}
.glyphicon-header:before{content:"\e180";}
.glyphicon-compressed:before{content:"\e181";}
.glyphicon-earphone:before{content:"\e182";}
.glyphicon-phone-alt:before{content:"\e183";}
.glyphicon-tower:before{content:"\e184";}
.glyphicon-stats:before{content:"\e185";}
.glyphicon-sd-video:before{content:"\e186";}
.glyphicon-hd-video:before{content:"\e187";}
.glyphicon-subtitles:before{content:"\e188";}
.glyphicon-sound-stereo:before{content:"\e189";}
.glyphicon-sound-dolby:before{content:"\e190";}
.glyphicon-sound-5-1:before{content:"\e191";}
.glyphicon-sound-6-1:before{content:"\e192";}
.glyphicon-sound-7-1:before{content:"\e193";}
.glyphicon-copyright-mark:before{content:"\e194";}
.glyphicon-registration-mark:before{content:"\e195";}
.glyphicon-cloud-download:before{content:"\e197";}
.glyphicon-cloud-upload:before{content:"\e198";}
.glyphicon-tree-conifer:before{content:"\e199";}
.glyphicon-tree-deciduous:before{content:"\e200";}
.glyphicon-briefcase:before{content:"\1f4bc";}
.glyphicon-calendar:before{content:"\1f4c5";}
.glyphicon-pushpin:before{content:"\1f4cc";}
.glyphicon-paperclip:before{content:"\1f4ce";}
.glyphicon-camera:before{content:"\1f4f7";}
.glyphicon-lock:before{content:"\1f512";}
.glyphicon-bell:before{content:"\1f514";}
.glyphicon-bookmark:before{content:"\1f516";}
.glyphicon-fire:before{content:"\1f525";}
.glyphicon-wrench:before{content:"\1f527";}

并将创建的css文件导入到我的主css文件中,这使我仅可以导入字形。希望这个帮助

@import url("bootstrap-glyphicons.css");
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.