【发布时间】:2015-03-23 23:04:34
【问题描述】:
我在网站上使用 Bootstrap 3 的字形图标。它在浏览器中运行良好,但在某些设备上却不能,因为它显示为问号。
我找到了这个修复:Some of Bootstrap3 glyphicons are not displayed correctly on phonegap android webview,它修复了设备上的问题,但现在 glyphicon 在 Firefox 中不起作用。 (我正在覆盖 Bootstrap 默认值以在我的 CSS 中使用实际的、非转义字形。)我想知道是否有一种方法可以使用 Firefox 的浏览器检测来编写一些 jquery 以删除我的 CSS 文件中的覆盖并恢复它回到 Bootstrap 的 CSS。
我找到了这个用于浏览器检测的 jQuery 插件:https://github.com/gabceb/jquery-browser-plugin
代码:
JS
if ( $.browser.mozilla ) {
$('a#calendar span').removeClass('glyphicon-calendar');
$('a#calendar span').css({'glyphicon-calendar:before': 'content: "\1f4c5"'});
}
CSS 覆盖 Bootstrap
/* fix glyph not showing on some devices--override the Bootstrap defaults to use the actual, non-escaped glyphs */
.glyphicon-calendar:before {
content: "\d83d\dcc5";
}
Bootstrap 的 CSS
.glyphicon-calendar:before {
content: "\1f4c5";
}
感谢您的帮助。
【问题讨论】:
-
你能看看我在Bootstrap glyphicon not showing in Form上的回答吗?
标签: twitter-bootstrap twitter-bootstrap-3 glyphicons