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:
- 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.
Option 1: Keep Using Glyphicons with Bootstrap 4
If you're set on sticking with Glyphicons, you can add them manually:
- Grab the Glyphicons CSS and font files (you can pull these from the Bootstrap 3 source code or the official Glyphicons repository)
- 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:
- 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">
- Insert icons using the
biclass 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-userorfas fa-star. - Material Icons: Google's sleek, material-design-based icon set, easy to implement with their CDN.
内容的提问来源于stack exchange,提问作者pankaj jha

