我在网站上使用 Bootstrap 3 的字形图标。它在浏览器中运行良好,但在某些设备上却不能,因为它显示为问号。
我找到了这个修复:一些 Bootstrap3 glyphicons 在 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";
}
谢谢您的帮助。