CSS Bootstrap Glyphicons 不使用本地 Bootstrap 版本渲染
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28645733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap Glyphicons not rendering using local Bootstrap version
提问by Rahul Satal
I am using bootstrap in django and it works perfectly for all other bootstrap classes except icon classes like: class="glyphicon glyphicon-download-alt"
我在 django 中使用引导程序,它适用于所有其他引导程序类,但图标类除外,例如: class="glyphicon glyphicon-download-alt"
Snapshot with error at right bottom:
右下角有错误的快照:
Snapshot when bootstrap.min.css file included:
包含 bootstrap.min.css 文件时的快照:
On doing inspect element it contain all glyphicons its snapshot is-
在执行检查元素时,它包含所有字形,其快照是-
It only works if I link http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css
in my html file; but it does'nt work if I include my bootstrap.min.css
from my PC. Otherwise, every bootstrap class works perfectly. Hope you understand my problem. Thanks in advance.
只有http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css
在我的 html 文件中链接时它才有效;但如果我bootstrap.min.css
从我的电脑中包含我的,它就不起作用。否则,每个引导类都可以完美运行。希望你明白我的问题。提前致谢。
回答by rnevius
It isn't working because you saved the CSS file from the CDN link. That won't work, because the glyphicons are linked to relative to that CSS file. Example:
它不起作用,因为您从 CDN 链接保存了 CSS 文件。这是行不通的,因为字形链接到相对于该 CSS 文件。例子:
@font-face{
font-family:'Glyphicons Halflings';
src:url(../fonts/glyphicons-halflings-regular.eot);
}
What this means, is that the downloaded Bootstrap file is looking for the glyphicons in a folder on your computer(which you don't have).
这意味着下载的 Bootstrap 文件正在您计算机上的文件夹(您没有)中查找字形。
You need to properly download Bootstrap from the official download link. This official download contains a /fonts/
directory that contains the actual glyphicon font files.
您需要从官方下载链接正确下载 Bootstrap 。此官方下载包含一个/fonts/
包含实际 glyphicon 字体文件的目录。
Alternatively, you could change all of the font paths in the CDN file to be absolute links to the fonts on the CDN...but that doesn't really make sense.
或者,您可以将 CDN 文件中的所有字体路径更改为指向 CDN 上字体的绝对链接……但这实际上没有意义。
回答by Rahul Satal
Finally my problem is resolved. Actually the problem was while using Glyphicons in our website like in django, we also have to copy font folder from bootstrap-3.3.2-dist folder downloaded from bootstrap official link
最后我的问题解决了。实际上问题是在我们的网站上使用 Glyphicons 时,就像在 django 中一样,我们还必须从bootstrap 官方链接下载的 bootstrap-3.3.2-dist 文件夹中复制字体文件夹
Another problem is where to fix it. See this structure where fonts is respect to css file and then paste fonts folder.
另一个问题是在哪里修复它。查看字体与 css 文件相关的结构,然后粘贴字体文件夹。
bootstrap/ ├── less/ ├── js/ ├── fonts/ ├── dist/ │ ├── css/ │ ├── js/ │ └── fonts/ └── docs/ └── examples/
But it worked for me in django just inside static folder.
但它在 Django 中对我有用,就在静态文件夹中。