html - Font Awesome 5:某些 unicode 不会在 html 选择中显示
问题描述
我有一个包含 2 个项目的 html 选择,每个项目都应该显示一个 FA 图标,但只有一个项目有效。两个图标都只有“已售”版本可用 FA5 免费。将字体系列更改为“Font Awesome 5 Free”,没有帮助,然后没有显示任何图标。
<html>
<head></head>
<body>
<style>
select {
font-family: 'FontAwesome';
}
</style>
<select style='font-weight: 900;'>
<option> Broke</option>
<option> Working</option>
</select>
<br/><br/> Code valid as this shows <i class='fas'></i><br/><br/> But displayed icons have the solid style as free and the other styles are pro only<br /> https://fontawesome.com/icons/graduation-cap?style=solid f19d<br /> https://fontawesome.com/icons/th-large?style=solid
f009<br />
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-1/js/all.js" crossorigin="anonymous"></script>
</body>
</html>
提前致谢
解决方案
您正在使用 JS+SVG 方法来加载图标,因此内容中使用的图标<i class='fas'></i>
将被转换为 SVG。选择中的 unicde 不被考虑在内,它将依赖于font-family: 'FontAwesome'
旧版本,并且您尝试显示的第一个图标仅存在于 V5 中(与第二个不同)。
要解决您的问题,您需要加载 CSS 版本并更正font-family
select {
font-family: 'Font Awesome 5 Free';
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0-1/css/all.css">
<select style='font-weight: 900;'>
<option> Broke</option>
<option> Working</option>
</select>
<br/><br/> Code valid as this shows <i class='fas'></i><br/><br/> But displayed icons have the solid style as free and the other styles are pro only<br /> https://fontawesome.com/icons/graduation-cap?style=solid f19d<br /> https://fontawesome.com/icons/th-large?style=solid
f009
<br />
推荐阅读
- ios - 我的 swift iOS 应用程序总是在 MainViewController 中启动 - 最初无法在 SceneDeletage 中导航到 LoginViewController
- sqlite - SQLite 浏览器“修改表后检查外键时出错。更改将被还原。”
- illegalstateexception - 即使线程持有 ReentrantLock 对象,也会发生 IllegalMonitorStateException
- ios - 无论选择什么行,SwiftUI 列表视图都会打开相同的 PDF - 也无法删除列表的扩展名
- isabelle - 一对空的“证明 qed”在 Isabelle 中是如何工作的?
- javascript - axios + 查询字符串与 jQuery,POST 数据被查询字符串破坏
- python - 如何根据条件 > 0 创建具有行值和列名的列
- python - Pandas:将每行数据存储到以列名为键的字典中
- python - YouTube Data API 如何提取超过 100 条评论?
- python - 如何检查 Python Tkinter 中是否存在菜单项