You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Bootstrap 4.0.0中Glyphicon无法使用的原因及替代方案咨询

Hey there, let's clear up why your Glyphicons aren't working in Bootstrap 4.0.0 and go through your options to fix this:

Why Glyphicons Break in Bootstrap 4
  • Bootstrap 4 officially removed Glyphicons from its core framework. The team made this call to slim down the package size and push users toward more modern, customizable icon libraries.
  • Bootstrap 3.x (like your 3.3.7 version) included Glyphicons by default—so all the necessary CSS and font files are baked right into that CDN link, which is why those icons work without extra setup.
Solutions & Alternatives

Option 1: Keep Using Glyphicons with Bootstrap 4

If you're set on sticking with Glyphicons, you can add them manually:

  1. Grab the Glyphicons CSS and font files (you can pull these from the Bootstrap 3 source code or the official Glyphicons repository)
  2. Host these files on your server, then add the Glyphicons stylesheet after your Bootstrap 4 CSS link to avoid conflicts:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="/path/to/your/glyphicons.css">

Pro tip: Double-check that the font paths in the Glyphicons CSS match where you've uploaded the font files (.eot, .woff, .ttf, etc.)—this is a common gotcha!

Option 2: Switch to Bootstrap's Official Icon Library

Bootstrap now has its own native icon set called Bootstrap Icons, built to work flawlessly with Bootstrap 4 and later versions. Here's how to use it:

  1. Add the Bootstrap Icons CDN link right after your Bootstrap 4 CSS:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
  1. Insert icons using the bi class prefix, like:
<i class="bi bi-heart-fill"></i>
<i class="bi bi-search"></i>

This is the most recommended approach—it's maintained by the Bootstrap team, lightweight, and integrates perfectly with Bootstrap's components.

Option 3: Use Third-Party Icon Libraries

If you want more variety, there are tons of popular, free icon libraries that play nice with Bootstrap:

  • Font Awesome: A massive library with thousands of icons. Add its CDN and use classes like fa fa-user or fas fa-star.
  • Material Icons: Google's sleek, material-design-based icon set, easy to implement with their CDN.

内容的提问来源于stack exchange,提问作者pankaj jha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:37:32